Merge branch 'refs/heads/dev' into test

This commit is contained in:
liss
2025-10-17 18:01:18 +08:00
84 changed files with 4307 additions and 874 deletions

View File

@@ -4,9 +4,7 @@ import com.zt.plat.framework.common.exception.ErrorCode;
/**
* base 错误码枚举类
*
* base 系统,使用 1-xxx-xxx-xxx 段
*
* @author ZT
*/
public interface ErrorCodeConstants {
@@ -22,4 +20,12 @@ public interface ErrorCodeConstants {
ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在");
ErrorCode FACTORY_NOT_EXISTS = new ErrorCode(1_001_000_001, "示例不存在");
ErrorCode BUSINESS_RULE_NOT_EXISTS = new ErrorCode(1_027_100_001, "规则模型不存在");
ErrorCode BUSINESS_ALGORITHM_NOT_EXISTS = new ErrorCode(1_027_100_002, "算法模型不存在");
ErrorCode BUSINESS_DIMENSION_NOT_EXISTS = new ErrorCode(1_027_200_001, "经营指标维度不存在");
ErrorCode BUSINESS_INDICATOR_NOT_EXISTS = new ErrorCode(1_027_200_002, "经营指标不存在");
ErrorCode BUSINESS_DICTIONARY_TYPE_NOT_EXISTS = new ErrorCode(1_027_200_003, "业务字典类型不存在");
ErrorCode BUSINESS_DEPARTMENT_INDICATOR_NOT_EXISTS = new ErrorCode(1_027_200_004, "部门持有指标不存在");
}

View File

@@ -0,0 +1,106 @@
package com.zt.plat.module.base.controller.admin.businessalgorithm;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
import com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.base.controller.admin.businessalgorithm.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessalgorithm.BusinessAlgorithmDO;
import com.zt.plat.module.base.service.businessalgorithm.BusinessAlgorithmService;
@Tag(name = "管理后台 - 业务算法")
@RestController
@RequestMapping("/base/business-algorithm")
@Validated
public class BusinessAlgorithmController implements BusinessControllerMarker {
@Resource
private BusinessAlgorithmService businessAlgorithmService;
@PostMapping("/create")
@Operation(summary = "创建业务算法")
@PreAuthorize("@ss.hasPermission('base:business-algorithm:create')")
public CommonResult<BusinessAlgorithmRespVO> createBusinessAlgorithm(@Valid @RequestBody BusinessAlgorithmSaveReqVO createReqVO) {
return success(businessAlgorithmService.createBusinessAlgorithm(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新业务算法")
@PreAuthorize("@ss.hasPermission('base:business-algorithm:update')")
public CommonResult<Boolean> updateBusinessAlgorithm(@Valid @RequestBody BusinessAlgorithmSaveReqVO updateReqVO) {
businessAlgorithmService.updateBusinessAlgorithm(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除业务算法")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:business-algorithm:delete')")
public CommonResult<Boolean> deleteBusinessAlgorithm(@RequestParam("id") Long id) {
businessAlgorithmService.deleteBusinessAlgorithm(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除业务算法")
@PreAuthorize("@ss.hasPermission('base:business-algorithm:delete')")
public CommonResult<Boolean> deleteBusinessAlgorithmList(@RequestBody BatchDeleteReqVO req) {
businessAlgorithmService.deleteBusinessAlgorithmListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得业务算法")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:business-algorithm:query')")
public CommonResult<BusinessAlgorithmRespVO> getBusinessAlgorithm(@RequestParam("id") Long id) {
BusinessAlgorithmDO businessAlgorithm = businessAlgorithmService.getBusinessAlgorithm(id);
return success(BeanUtils.toBean(businessAlgorithm, BusinessAlgorithmRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得业务算法分页")
@PreAuthorize("@ss.hasPermission('base:business-algorithm:query')")
public CommonResult<PageResult<BusinessAlgorithmRespVO>> getBusinessAlgorithmPage(@Valid BusinessAlgorithmPageReqVO pageReqVO) {
PageResult<BusinessAlgorithmDO> pageResult = businessAlgorithmService.getBusinessAlgorithmPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, BusinessAlgorithmRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出业务算法 Excel")
@PreAuthorize("@ss.hasPermission('base:business-algorithm:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportBusinessAlgorithmExcel(@Valid BusinessAlgorithmPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<BusinessAlgorithmDO> list = businessAlgorithmService.getBusinessAlgorithmPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "业务算法.xls", "数据", BusinessAlgorithmRespVO.class,
BeanUtils.toBean(list, BusinessAlgorithmRespVO.class));
}
}

View File

@@ -0,0 +1,23 @@
package com.zt.plat.module.base.controller.admin.businessalgorithm.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 业务算法分页 Request VO")
@Data
public class BusinessAlgorithmPageReqVO extends PageParam {
@Schema(description = "类型")
private String typeValue;
@Schema(description = "状态")
private String statusValue;
@Schema(description = "算法编码")
private String code;
@Schema(description = "算法名称", example = "王五")
private String name;
}

View File

@@ -0,0 +1,45 @@
package com.zt.plat.module.base.controller.admin.businessalgorithm.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 业务算法 Response VO")
@Data
@ExcelIgnoreUnannotated
public class BusinessAlgorithmRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "24454")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("类型")
private String typeValue;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("状态")
private String statusValue;
@Schema(description = "算法编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("算法编码")
private String code;
@Schema(description = "算法名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("算法名称")
private String name;
@Schema(description = "算法描述", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("算法描述")
private String description;
@Schema(description = "算法代码")
@ExcelProperty("算法代码")
private String coding;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,37 @@
package com.zt.plat.module.base.controller.admin.businessalgorithm.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - 业务算法新增/修改 Request VO")
@Data
public class BusinessAlgorithmSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "24454")
private Long id;
@Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "类型不能为空")
private String typeValue;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "状态不能为空")
private String statusValue;
@Schema(description = "算法编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "算法编码不能为空")
private String code;
@Schema(description = "算法名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "算法名称不能为空")
private String name;
@Schema(description = "算法描述", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "算法描述不能为空")
private String description;
@Schema(description = "算法代码")
private String coding;
}

View File

@@ -0,0 +1,107 @@
package com.zt.plat.module.base.controller.admin.businessdepartmentindicator;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
import com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.base.controller.admin.businessdepartmentindicator.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessdepartmentindicator.BusinessDepartmentIndicatorDO;
import com.zt.plat.module.base.service.businessdepartmentindicator.BusinessDepartmentIndicatorService;
@Tag(name = "管理后台 - 部门持有指标")
@RestController
@RequestMapping("/base/business-department-indicator")
@Validated
public class BusinessDepartmentIndicatorController implements BusinessControllerMarker {
@Resource
private BusinessDepartmentIndicatorService businessDepartmentIndicatorService;
@PostMapping("/create")
@Operation(summary = "创建部门持有指标")
@PreAuthorize("@ss.hasPermission('base:business-department-indicator:create')")
public CommonResult<BusinessDepartmentIndicatorRespVO> createBusinessDepartmentIndicator(@Valid @RequestBody BusinessDepartmentIndicatorSaveReqVO createReqVO) {
return success(businessDepartmentIndicatorService.createBusinessDepartmentIndicator(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新部门持有指标")
@PreAuthorize("@ss.hasPermission('base:business-department-indicator:update')")
public CommonResult<Boolean> updateBusinessDepartmentIndicator(@Valid @RequestBody BusinessDepartmentIndicatorSaveReqVO updateReqVO) {
businessDepartmentIndicatorService.updateBusinessDepartmentIndicator(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除部门持有指标")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:business-department-indicator:delete')")
public CommonResult<Boolean> deleteBusinessDepartmentIndicator(@RequestParam("id") Long id) {
businessDepartmentIndicatorService.deleteBusinessDepartmentIndicator(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除部门持有指标")
@PreAuthorize("@ss.hasPermission('base:business-department-indicator:delete')")
public CommonResult<Boolean> deleteBusinessDepartmentIndicatorList(@RequestBody BatchDeleteReqVO req) {
businessDepartmentIndicatorService.deleteBusinessDepartmentIndicatorListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得部门持有指标")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:business-department-indicator:query')")
public CommonResult<BusinessDepartmentIndicatorRespVO> getBusinessDepartmentIndicator(@RequestParam("id") Long id) {
BusinessDepartmentIndicatorDO businessDepartmentIndicator = businessDepartmentIndicatorService.getBusinessDepartmentIndicator(id);
return success(BeanUtils.toBean(businessDepartmentIndicator, BusinessDepartmentIndicatorRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得部门持有指标分页")
@PreAuthorize("@ss.hasPermission('base:business-department-indicator:query')")
public CommonResult<PageResult<BusinessDepartmentIndicatorRespVO>> getBusinessDepartmentIndicatorPage(@Valid BusinessDepartmentIndicatorPageReqVO pageReqVO) {
PageResult<BusinessDepartmentIndicatorDO> pageResult = businessDepartmentIndicatorService.getBusinessDepartmentIndicatorPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, BusinessDepartmentIndicatorRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出部门持有指标 Excel")
@PreAuthorize("@ss.hasPermission('base:business-department-indicator:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportBusinessDepartmentIndicatorExcel(@Valid BusinessDepartmentIndicatorPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<BusinessDepartmentIndicatorDO> list = businessDepartmentIndicatorService.getBusinessDepartmentIndicatorPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "部门持有指标.xls", "数据", BusinessDepartmentIndicatorRespVO.class,
BeanUtils.toBean(list, BusinessDepartmentIndicatorRespVO.class));
}
}

View File

@@ -0,0 +1,17 @@
package com.zt.plat.module.base.controller.admin.businessdepartmentindicator.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 部门持有指标分页 Request VO")
@Data
public class BusinessDepartmentIndicatorPageReqVO extends PageParam {
@Schema(description = "指标ID", example = "11268")
private Long indicatorId;
@Schema(description = "是否关键指标")
private Integer isKey;
}

View File

@@ -0,0 +1,59 @@
package com.zt.plat.module.base.controller.admin.businessdepartmentindicator.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 部门持有指标 Response VO")
@Data
@ExcelIgnoreUnannotated
public class BusinessDepartmentIndicatorRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32066")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "指标ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11268")
@ExcelProperty("指标ID")
private Long indicatorId;
@Schema(description = "计量单位ID", example = "16200")
@ExcelProperty("计量单位ID")
private Long unitId;
@Schema(description = "规则ID", example = "11174")
@ExcelProperty("规则ID")
private Long ruleId;
@Schema(description = "算法ID", example = "20986")
@ExcelProperty("算法ID")
private Long algorithmId;
@Schema(description = "实体ID", example = "2678")
@ExcelProperty("实体ID")
private Long entityId;
@Schema(description = "")
@ExcelProperty("")
private String value;
@Schema(description = "是否关键指标")
@ExcelProperty("是否关键指标")
private Integer isKey;
@Schema(description = "排序号")
@ExcelProperty("排序号")
private Long sort;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,43 @@
package com.zt.plat.module.base.controller.admin.businessdepartmentindicator.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - 部门持有指标新增/修改 Request VO")
@Data
public class BusinessDepartmentIndicatorSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32066")
private Long id;
@Schema(description = "指标ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11268")
@NotNull(message = "指标ID不能为空")
private Long indicatorId;
@Schema(description = "计量单位ID", example = "16200")
private Long unitId;
@Schema(description = "规则ID", example = "11174")
private Long ruleId;
@Schema(description = "算法ID", example = "20986")
private Long algorithmId;
@Schema(description = "实体ID", example = "2678")
private Long entityId;
@Schema(description = "")
private String value;
@Schema(description = "是否关键指标")
private Integer isKey;
@Schema(description = "排序号")
private Long sort;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "备注不能为空")
private String remark;
}

View File

@@ -0,0 +1,119 @@
package com.zt.plat.module.base.controller.admin.businessdictionarytype;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
import com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryTypeDO;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
import com.zt.plat.module.base.service.businessdictionarytype.BusinessDictionaryTypeService;
@Tag(name = "管理后台 - 业务字典类型")
@RestController
@RequestMapping("/base/business-dictionary-type")
@Validated
public class BusinessDictionaryTypeController implements BusinessControllerMarker {
@Resource
private BusinessDictionaryTypeService businessDictionaryTypeService;
@PostMapping("/create")
@Operation(summary = "创建业务字典类型")
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:create')")
public CommonResult<BusinessDictionaryTypeRespVO> createBusinessDictionaryType(@Valid @RequestBody BusinessDictionaryTypeSaveReqVO createReqVO) {
return success(businessDictionaryTypeService.createBusinessDictionaryType(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新业务字典类型")
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:update')")
public CommonResult<Boolean> updateBusinessDictionaryType(@Valid @RequestBody BusinessDictionaryTypeSaveReqVO updateReqVO) {
businessDictionaryTypeService.updateBusinessDictionaryType(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除业务字典类型")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:delete')")
public CommonResult<Boolean> deleteBusinessDictionaryType(@RequestParam("id") Long id) {
businessDictionaryTypeService.deleteBusinessDictionaryType(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除业务字典类型")
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:delete')")
public CommonResult<Boolean> deleteBusinessDictionaryTypeList(@RequestBody BatchDeleteReqVO req) {
businessDictionaryTypeService.deleteBusinessDictionaryTypeListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得业务字典类型")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:query')")
public CommonResult<BusinessDictionaryTypeRespVO> getBusinessDictionaryType(@RequestParam("id") Long id) {
BusinessDictionaryTypeDO businessDictionaryType = businessDictionaryTypeService.getBusinessDictionaryType(id);
return success(BeanUtils.toBean(businessDictionaryType, BusinessDictionaryTypeRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得业务字典类型分页")
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:query')")
public CommonResult<PageResult<BusinessDictionaryTypeRespVO>> getBusinessDictionaryTypePage(@Valid BusinessDictionaryTypePageReqVO pageReqVO) {
PageResult<BusinessDictionaryTypeDO> pageResult = businessDictionaryTypeService.getBusinessDictionaryTypePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, BusinessDictionaryTypeRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出业务字典类型 Excel")
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportBusinessDictionaryTypeExcel(@Valid BusinessDictionaryTypePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<BusinessDictionaryTypeDO> list = businessDictionaryTypeService.getBusinessDictionaryTypePage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "业务字典类型.xls", "数据", BusinessDictionaryTypeRespVO.class,
BeanUtils.toBean(list, BusinessDictionaryTypeRespVO.class));
}
// ==================== 子表(业务字典数据) ====================
@GetMapping("/business-dictionary-data/list-by-dictionary-type-id")
@Operation(summary = "获得业务字典数据列表")
@Parameter(name = "dictionaryTypeId", description = "字典类型")
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:query')")
public CommonResult<List<BusinessDictionaryDataDO>> getBusinessDictionaryDataListByDictionaryTypeId(@RequestParam("dictionaryTypeId") Long dictionaryTypeId) {
return success(businessDictionaryTypeService.getBusinessDictionaryDataListByDictionaryTypeId(dictionaryTypeId));
}
}

View File

@@ -0,0 +1,20 @@
package com.zt.plat.module.base.controller.admin.businessdictionarytype.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 业务字典类型分页 Request VO")
@Data
public class BusinessDictionaryTypePageReqVO extends PageParam {
@Schema(description = "字典名称", example = "王五")
private String name;
@Schema(description = "字典类型", example = "1")
private String type;
@Schema(description = "状态(0正常 1停用)", example = "2")
private Long status;
}

View File

@@ -0,0 +1,37 @@
package com.zt.plat.module.base.controller.admin.businessdictionarytype.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 业务字典类型 Response VO")
@Data
@ExcelIgnoreUnannotated
public class BusinessDictionaryTypeRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11771")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "字典名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("字典名称")
private String name;
@Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("字典类型")
private String type;
@Schema(description = "状态(0正常 1停用)", example = "2")
@ExcelProperty("状态(0正常 1停用)")
private Long status;
@Schema(description = "备注")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,37 @@
package com.zt.plat.module.base.controller.admin.businessdictionarytype.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import jakarta.validation.constraints.*;
import java.time.LocalDateTime;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
@Schema(description = "管理后台 - 业务字典类型新增/修改 Request VO")
@Data
public class BusinessDictionaryTypeSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11771")
private Long id;
@Schema(description = "字典名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "字典名称不能为空")
private String name;
@Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotEmpty(message = "字典类型不能为空")
private String type;
@Schema(description = "状态(0正常 1停用)", example = "2")
private Long status;
@Schema(description = "备注")
private String remark;
@Schema(description = "删除时间")
private LocalDateTime delTime;
@Schema(description = "业务字典数据列表")
private List<BusinessDictionaryDataDO> businessDictionaryDatas;
}

View File

@@ -0,0 +1,118 @@
package com.zt.plat.module.base.controller.admin.businessdimension;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
import com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.base.controller.admin.businessdimension.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessdimension.BusinessDimensionDO;
import com.zt.plat.module.base.service.businessdimension.BusinessDimensionService;
@Tag(name = "管理后台 - 经营指标维度")
@RestController
@RequestMapping("/base/business-dimension")
@Validated
public class BusinessDimensionController implements BusinessControllerMarker {
@Resource
private BusinessDimensionService businessDimensionService;
@PostMapping("/create")
@Operation(summary = "创建经营指标维度")
@PreAuthorize("@ss.hasPermission('base:business-dimension:create')")
public CommonResult<BusinessDimensionRespVO> createBusinessDimension(@Valid @RequestBody BusinessDimensionSaveReqVO createReqVO) {
return success(businessDimensionService.createBusinessDimension(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新经营指标维度")
@PreAuthorize("@ss.hasPermission('base:business-dimension:update')")
public CommonResult<Boolean> updateBusinessDimension(@Valid @RequestBody BusinessDimensionSaveReqVO updateReqVO) {
businessDimensionService.updateBusinessDimension(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除经营指标维度")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:business-dimension:delete')")
public CommonResult<Boolean> deleteBusinessDimension(@RequestParam("id") Long id) {
businessDimensionService.deleteBusinessDimension(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除经营指标维度")
@PreAuthorize("@ss.hasPermission('base:business-dimension:delete')")
public CommonResult<Boolean> deleteBusinessDimensionList(@RequestBody BatchDeleteReqVO req) {
businessDimensionService.deleteBusinessDimensionListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得经营指标维度")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:business-dimension:query')")
public CommonResult<BusinessDimensionRespVO> getBusinessDimension(@RequestParam("id") Long id) {
BusinessDimensionDO businessDimension = businessDimensionService.getBusinessDimension(id);
return success(BeanUtils.toBean(businessDimension, BusinessDimensionRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得经营指标维度分页")
@PreAuthorize("@ss.hasPermission('base:business-dimension:query')")
public CommonResult<PageResult<BusinessDimensionRespVO>> getBusinessDimensionPage(@Valid BusinessDimensionPageReqVO pageReqVO) {
PageResult<BusinessDimensionDO> pageResult = businessDimensionService.getBusinessDimensionPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, BusinessDimensionRespVO.class));
}
@GetMapping("/list-by-parent-id")
@Operation(summary = "获得经营指标维度列表通过父级ID")
@Parameter(name = "parentId", description = "父级ID", example = "0")
@PreAuthorize("@ss.hasPermission('base:business-dimension:query')")
public CommonResult<List<BusinessDimensionRespVO>> getBusinessDimensionListByParentId(@RequestParam(value = "parentId", required = false) Long parentId,
@RequestParam(value = "level", required = false) Integer level) {
List<BusinessDimensionDO> list = businessDimensionService.getBusinessDimensionListByParentId(parentId, level);
return success(BeanUtils.toBean(list, BusinessDimensionRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出经营指标维度 Excel")
@PreAuthorize("@ss.hasPermission('base:business-dimension:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportBusinessDimensionExcel(@Valid BusinessDimensionPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<BusinessDimensionDO> list = businessDimensionService.getBusinessDimensionPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "经营指标维度.xls", "数据", BusinessDimensionRespVO.class,
BeanUtils.toBean(list, BusinessDimensionRespVO.class));
}
}

View File

@@ -0,0 +1,28 @@
package com.zt.plat.module.base.controller.admin.businessdimension.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 经营指标维度分页 Request VO")
@Data
public class BusinessDimensionPageReqVO extends PageParam {
@Schema(description = "维度类型")
private String typeValue;
@Schema(description = "维度编码")
private String code;
@Schema(description = "维度名称", example = "王五")
private String name;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -0,0 +1,44 @@
package com.zt.plat.module.base.controller.admin.businessdimension.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import com.zt.plat.framework.excel.core.annotations.DictFormat;
import com.zt.plat.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 经营指标维度 Response VO")
@Data
@ExcelIgnoreUnannotated
public class BusinessDimensionRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5174")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "父级ID", example = "29218")
@ExcelProperty("父级ID")
private Long parentId;
@Schema(description = "维度类型", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty(value = "维度类型", converter = DictConvert.class)
@DictFormat("demo_contract") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String typeValue;
@Schema(description = "维度编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("维度编码")
private String code;
@Schema(description = "维度名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("维度名称")
private String name;
@Schema(description = "备注")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,32 @@
package com.zt.plat.module.base.controller.admin.businessdimension.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - 经营指标维度新增/修改 Request VO")
@Data
public class BusinessDimensionSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5174")
private Long id;
@Schema(description = "父级ID", example = "29218")
private Long parentId;
@Schema(description = "维度类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "维度类型不能为空")
private String typeValue;
@Schema(description = "维度编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "维度编码不能为空")
private String code;
@Schema(description = "维度名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "维度名称不能为空")
private String name;
@Schema(description = "备注")
private String remark;
}

View File

@@ -0,0 +1,128 @@
package com.zt.plat.module.base.controller.admin.businessindicator;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import com.zt.plat.framework.business.annotation.FileUploadController;
import com.zt.plat.framework.business.controller.AbstractFileUploadController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
import com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.base.controller.admin.businessindicator.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessindicator.BusinessIndicatorDO;
import com.zt.plat.module.base.service.businessindicator.BusinessIndicatorService;
@Tag(name = "管理后台 - 经营指标")
@RestController
@RequestMapping("/base/business-indicator")
@Validated
@FileUploadController(source = "base.businessindicator")
public class BusinessIndicatorController extends AbstractFileUploadController implements BusinessControllerMarker{
static {
FileUploadController annotation = BusinessIndicatorController.class.getAnnotation(FileUploadController.class);
if (annotation != null) {
setFileUploadInfo(annotation);
}
}
@Resource
private BusinessIndicatorService businessIndicatorService;
@PostMapping("/create")
@Operation(summary = "创建经营指标")
@PreAuthorize("@ss.hasPermission('base:business-indicator:create')")
public CommonResult<BusinessIndicatorRespVO> createBusinessIndicator(@Valid @RequestBody BusinessIndicatorSaveReqVO createReqVO) {
return success(businessIndicatorService.createBusinessIndicator(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新经营指标")
@PreAuthorize("@ss.hasPermission('base:business-indicator:update')")
public CommonResult<Boolean> updateBusinessIndicator(@Valid @RequestBody BusinessIndicatorSaveReqVO updateReqVO) {
businessIndicatorService.updateBusinessIndicator(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除经营指标")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:business-indicator:delete')")
public CommonResult<Boolean> deleteBusinessIndicator(@RequestParam("id") Long id) {
businessIndicatorService.deleteBusinessIndicator(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除经营指标")
@PreAuthorize("@ss.hasPermission('base:business-indicator:delete')")
public CommonResult<Boolean> deleteBusinessIndicatorList(@RequestBody BatchDeleteReqVO req) {
businessIndicatorService.deleteBusinessIndicatorListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得经营指标")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:business-indicator:query')")
public CommonResult<BusinessIndicatorRespVO> getBusinessIndicator(@RequestParam("id") Long id) {
// BusinessIndicatorDO businessIndicator = businessIndicatorService.getBusinessIndicator(id);
// 使用getBusinessIndicatorPageWithRelations方法
BusinessIndicatorPageReqVO pageReqVO = new BusinessIndicatorPageReqVO();
pageReqVO.setId(id);
BusinessIndicatorRespVO businessIndicator = businessIndicatorService.getBusinessIndicatorPageWithRelations(pageReqVO).getList().get(0);
return success(BeanUtils.toBean(businessIndicator, BusinessIndicatorRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得经营指标分页")
@PreAuthorize("@ss.hasPermission('base:business-indicator:query')")
public CommonResult<PageResult<BusinessIndicatorRespVO>> getBusinessIndicatorPage(@Valid BusinessIndicatorPageReqVO pageReqVO) {
PageResult<BusinessIndicatorRespVO> pageResult = businessIndicatorService.getBusinessIndicatorPageWithRelations(pageReqVO);
return success(pageResult);
}
@GetMapping("/export-excel")
@Operation(summary = "导出经营指标 Excel")
@PreAuthorize("@ss.hasPermission('base:business-indicator:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportBusinessIndicatorExcel(@Valid BusinessIndicatorPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<BusinessIndicatorDO> list = businessIndicatorService.getBusinessIndicatorPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "经营指标.xls", "数据", BusinessIndicatorRespVO.class,
BeanUtils.toBean(list, BusinessIndicatorRespVO.class));
}
@GetMapping("/list-by-parent-id")
@Operation(summary = "获得经营指标列表通过父级ID")
@Parameter(name = "parentId", description = "父级ID", example = "0")
@PreAuthorize("@ss.hasPermission('base:business-indicator:query')")
public CommonResult<List<BusinessIndicatorRespVO>> getBusinessIndicatorListByParentId(@RequestParam(value = "parentId", required = false) Long parentId) {
List<BusinessIndicatorDO> list = businessIndicatorService.getBusinessIndicatorListByParentId(parentId);
return success(BeanUtils.toBean(list, BusinessIndicatorRespVO.class));
}
}

View File

@@ -0,0 +1,23 @@
package com.zt.plat.module.base.controller.admin.businessindicator.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 经营指标分页 Request VO")
@Data
public class BusinessIndicatorPageReqVO extends PageParam {
@Schema(description = "指标编码")
private String code;
@Schema(description = "指标名称", example = "芋艿")
private String name;
@Schema(description = "指标ID")
private Long id;
@Schema(description = "维度ID")
private Long dimensionId;
}

View File

@@ -0,0 +1,93 @@
package com.zt.plat.module.base.controller.admin.businessindicator.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 经营指标 Response VO")
@Data
@ExcelIgnoreUnannotated
public class BusinessIndicatorRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3512")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "父级ID", example = "12917")
@ExcelProperty("父级ID")
private Long parentId;
@Schema(description = "指标编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("指标编码")
private String code;
@Schema(description = "指标名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("指标名称")
private String name;
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("数据类型")
private String dataValue;
@Schema(description = "计量单位量ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17208")
@ExcelProperty("计量单位量ID")
private Long quantityId;
@Schema(description = "计量单位ID", example = "31355")
@ExcelProperty("计量单位ID")
private Long unitId;
@Schema(description = "算法ID", example = "2240")
@ExcelProperty("算法ID")
private Long algorithmId;
@Schema(description = "规则ID", example = "32155")
@ExcelProperty("规则ID")
private Long ruleId;
@Schema(description = "维度ID", example = "7598")
@ExcelProperty("维度ID")
private Long dimensionId;
@Schema(description = "周期类型值", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("周期类型值")
private String cycleValue;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("状态")
private String statusValue;
@Schema(description = "是否可修改")
@ExcelProperty("是否可修改")
private Integer isModify;
@Schema(description = "用户ID", example = "13550")
@ExcelProperty("用户ID")
private Long userId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
// 新增关联名称字段
@Schema(description = "算法模型名称")
private String algorithmName;
@Schema(description = "算法类型值")
private String algorithmTypeValue;
@Schema(description = "规则模型名称")
private String ruleName;
@Schema(description = "规则类型值")
private String ruleTypeValue;
@Schema(description = "负责人名称")
private String userName;
@Schema(description = "指标描述")
private String description;
}

View File

@@ -0,0 +1,63 @@
package com.zt.plat.module.base.controller.admin.businessindicator.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - 经营指标新增/修改 Request VO")
@Data
public class BusinessIndicatorSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3512")
private Long id;
@Schema(description = "父级ID", example = "12917")
private Long parentId;
@Schema(description = "指标编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "指标编码不能为空")
private String code;
@Schema(description = "指标名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "指标名称不能为空")
private String name;
@Schema(description = "指标描述", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "指标描述不能为空")
private String description;
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "数据类型不能为空")
private String dataValue;
@Schema(description = "计量单位量ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17208")
private Long quantityId;
@Schema(description = "计量单位ID", example = "31355")
private Long unitId;
@Schema(description = "算法ID", example = "2240")
private Long algorithmId;
@Schema(description = "规则ID", example = "32155")
private Long ruleId;
@Schema(description = "维度ID", example = "7598")
private Long dimensionId;
@Schema(description = "周期类型值", requiredMode = Schema.RequiredMode.REQUIRED)
private String cycleValue;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "状态不能为空")
private String statusValue;
@Schema(description = "是否可修改")
private boolean isModify;
@Schema(description = "负责人ID", example = "13550")
private Long userId;
@Schema(description = "负责部门")
private String departmentId;
}

View File

@@ -0,0 +1,105 @@
package com.zt.plat.module.base.controller.admin.businessrule;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
import com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.base.controller.admin.businessrule.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessrule.BusinessRuleDO;
import com.zt.plat.module.base.service.businessrule.BusinessRuleService;
@Tag(name = "管理后台 - 业务规则")
@RestController
@RequestMapping("/base/business-rule")
@Validated
public class BusinessRuleController implements BusinessControllerMarker {
@Resource
private BusinessRuleService businessRuleService;
@PostMapping("/create")
@Operation(summary = "创建业务规则")
@PreAuthorize("@ss.hasPermission('base:business-rule:create')")
public CommonResult<BusinessRuleRespVO> createBusinessRule(@Valid @RequestBody BusinessRuleSaveReqVO createReqVO) {
return success(businessRuleService.createBusinessRule(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新业务规则")
@PreAuthorize("@ss.hasPermission('base:business-rule:update')")
public CommonResult<Boolean> updateBusinessRule(@Valid @RequestBody BusinessRuleSaveReqVO updateReqVO) {
businessRuleService.updateBusinessRule(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除业务规则")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:business-rule:delete')")
public CommonResult<Boolean> deleteBusinessRule(@RequestParam("id") Long id) {
businessRuleService.deleteBusinessRule(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除业务规则")
@PreAuthorize("@ss.hasPermission('base:business-rule:delete')")
public CommonResult<Boolean> deleteBusinessRuleList(@RequestBody BatchDeleteReqVO req) {
businessRuleService.deleteBusinessRuleListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得业务规则")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:business-rule:query')")
public CommonResult<BusinessRuleRespVO> getBusinessRule(@RequestParam("id") Long id) {
BusinessRuleDO businessRule = businessRuleService.getBusinessRule(id);
return success(BeanUtils.toBean(businessRule, BusinessRuleRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得业务规则分页")
@PreAuthorize("@ss.hasPermission('base:business-rule:query')")
public CommonResult<PageResult<BusinessRuleRespVO>> getBusinessRulePage(@Valid BusinessRulePageReqVO pageReqVO) {
PageResult<BusinessRuleDO> pageResult = businessRuleService.getBusinessRulePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, BusinessRuleRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出业务规则 Excel")
@PreAuthorize("@ss.hasPermission('base:business-rule:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportBusinessRuleExcel(@Valid BusinessRulePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<BusinessRuleDO> list = businessRuleService.getBusinessRulePage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "业务规则.xls", "数据", BusinessRuleRespVO.class,
BeanUtils.toBean(list, BusinessRuleRespVO.class));
}
}

View File

@@ -0,0 +1,23 @@
package com.zt.plat.module.base.controller.admin.businessrule.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 业务规则分页 Request VO")
@Data
public class BusinessRulePageReqVO extends PageParam {
@Schema(description = "状态")
private String statusValue;
@Schema(description = "类型")
private String typeValue;
@Schema(description = "规则编码")
private String code;
@Schema(description = "规则名称", example = "李四")
private String name;
}

View File

@@ -0,0 +1,45 @@
package com.zt.plat.module.base.controller.admin.businessrule.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 业务规则 Response VO")
@Data
@ExcelIgnoreUnannotated
public class BusinessRuleRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32088")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("状态")
private String statusValue;
@Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("类型")
private String typeValue;
@Schema(description = "规则编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("规则编码")
private String code;
@Schema(description = "规则名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@ExcelProperty("规则名称")
private String name;
@Schema(description = "规则描述", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("规则描述")
private String description;
@Schema(description = "规则表达式")
@ExcelProperty("规则表达式")
private String expression;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,37 @@
package com.zt.plat.module.base.controller.admin.businessrule.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - 业务规则新增/修改 Request VO")
@Data
public class BusinessRuleSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32088")
private Long id;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "状态不能为空")
private String statusValue;
@Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "类型不能为空")
private String typeValue;
@Schema(description = "规则编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "规则编码不能为空")
private String code;
@Schema(description = "规则名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@NotEmpty(message = "规则名称不能为空")
private String name;
@Schema(description = "规则描述", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "规则描述不能为空")
private String description;
@Schema(description = "规则表达式")
private String expression;
}

View File

@@ -0,0 +1,27 @@
package com.zt.plat.module.base.dal.dao.businessalgorithm;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.base.dal.dataobject.businessalgorithm.BusinessAlgorithmDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.base.controller.admin.businessalgorithm.vo.*;
/**
* 业务算法 Mapper
*
* @author yangxiaofeng
*/
@Mapper
public interface BusinessAlgorithmMapper extends BaseMapperX<BusinessAlgorithmDO> {
default PageResult<BusinessAlgorithmDO> selectPage(BusinessAlgorithmPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BusinessAlgorithmDO>()
.eqIfPresent(BusinessAlgorithmDO::getTypeValue, reqVO.getTypeValue())
.eqIfPresent(BusinessAlgorithmDO::getStatusValue, reqVO.getStatusValue())
.eqIfPresent(BusinessAlgorithmDO::getCode, reqVO.getCode())
.likeIfPresent(BusinessAlgorithmDO::getName, reqVO.getName())
.orderByDesc(BusinessAlgorithmDO::getId));
}
}

View File

@@ -0,0 +1,25 @@
package com.zt.plat.module.base.dal.dao.businessdepartmentindicator;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.base.dal.dataobject.businessdepartmentindicator.BusinessDepartmentIndicatorDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.base.controller.admin.businessdepartmentindicator.vo.*;
/**
* 部门持有指标 Mapper
*
* @author YangXiaofeng
*/
@Mapper
public interface BusinessDepartmentIndicatorMapper extends BaseMapperX<BusinessDepartmentIndicatorDO> {
default PageResult<BusinessDepartmentIndicatorDO> selectPage(BusinessDepartmentIndicatorPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BusinessDepartmentIndicatorDO>()
.eqIfPresent(BusinessDepartmentIndicatorDO::getIndicatorId, reqVO.getIndicatorId())
.eqIfPresent(BusinessDepartmentIndicatorDO::getIsKey, reqVO.getIsKey())
.orderByDesc(BusinessDepartmentIndicatorDO::getId));
}
}

View File

@@ -0,0 +1,29 @@
package com.zt.plat.module.base.dal.dao.businessdictionarytype;
import java.util.*;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 业务字典数据 Mapper
*
* @author yangxiaofeng
*/
@Mapper
public interface BusinessDictionaryDataMapper extends BaseMapperX<BusinessDictionaryDataDO> {
default List<BusinessDictionaryDataDO> selectListByDictionaryTypeId(Long dictionaryTypeId) {
return selectList(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeId);
}
default int deleteByDictionaryTypeId(Long dictionaryTypeId) {
return delete(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeId);
}
default int deleteByDictionaryTypeIds(List<Long> dictionaryTypeIds) {
return deleteBatch(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeIds);
}
}

View File

@@ -0,0 +1,26 @@
package com.zt.plat.module.base.dal.dao.businessdictionarytype;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryTypeDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.*;
/**
* 业务字典类型 Mapper
*
* @author 后台管理
*/
@Mapper
public interface BusinessDictionaryTypeMapper extends BaseMapperX<BusinessDictionaryTypeDO> {
default PageResult<BusinessDictionaryTypeDO> selectPage(BusinessDictionaryTypePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BusinessDictionaryTypeDO>()
.likeIfPresent(BusinessDictionaryTypeDO::getName, reqVO.getName())
.likeIfPresent(BusinessDictionaryTypeDO::getType, reqVO.getType())
.eqIfPresent(BusinessDictionaryTypeDO::getStatus, reqVO.getStatus())
.orderByDesc(BusinessDictionaryTypeDO::getId));
}
}

View File

@@ -0,0 +1,55 @@
package com.zt.plat.module.base.dal.dao.businessdimension;
import java.util.*;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.base.dal.dataobject.businessdimension.BusinessDimensionDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.base.controller.admin.businessdimension.vo.*;
/**
* 经营指标维度 Mapper
*
* @author 陈鹏
*/
@Mapper
public interface BusinessDimensionMapper extends BaseMapperX<BusinessDimensionDO> {
default PageResult<BusinessDimensionDO> selectPage(BusinessDimensionPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BusinessDimensionDO>()
.eqIfPresent(BusinessDimensionDO::getTypeValue, reqVO.getTypeValue())
.eqIfPresent(BusinessDimensionDO::getCode, reqVO.getCode())
.likeIfPresent(BusinessDimensionDO::getName, reqVO.getName())
.betweenIfPresent(BusinessDimensionDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(BusinessDimensionDO::getId));
}
// 获取子节点, 递归查询
default List<BusinessDimensionDO> selectListByParentId(Long parentId, Integer level) {
LambdaQueryWrapperX<BusinessDimensionDO> queryWrapper = new LambdaQueryWrapperX<BusinessDimensionDO>();
// 构建层次查询SQL
StringBuilder hierarchySql = new StringBuilder();
hierarchySql.append("START WITH ");
if (parentId == null) {
hierarchySql.append("PRN_ID IS NULL ");
} else {
hierarchySql.append("PRN_ID = ").append(parentId);
}
if (level == null)
hierarchySql.append(" CONNECT BY PRIOR PRN_ID = ID ");
else if (level < 0) //对level取绝对值
hierarchySql.append(" CONNECT BY PRIOR PRN_ID = ID AND LEVEL <= ").append(-level);
else
hierarchySql.append(" CONNECT BY PRIOR ID = PRN_ID AND LEVEL <= ").append(level);
hierarchySql.append(" ORDER SIBLINGS BY ID DESC");
queryWrapper.last(hierarchySql.toString());
return selectList(queryWrapper);
}
}

View File

@@ -0,0 +1,43 @@
package com.zt.plat.module.base.dal.dao.businessindicator;
import java.util.*;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.base.dal.dataobject.businessindicator.BusinessIndicatorDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.base.controller.admin.businessindicator.vo.*;
/**
* 经营指标 Mapper
*
* @author chengpeng
*/
@Mapper
public interface BusinessIndicatorMapper extends BaseMapperX<BusinessIndicatorDO> {
default PageResult<BusinessIndicatorDO> selectPage(BusinessIndicatorPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BusinessIndicatorDO>()
.likeIfPresent(BusinessIndicatorDO::getCode, reqVO.getCode())
.likeIfPresent(BusinessIndicatorDO::getName, reqVO.getName())
.eqIfPresent(BusinessIndicatorDO::getDimensionId, reqVO.getDimensionId())
.eqIfPresent(BusinessIndicatorDO::getId, reqVO.getId())
.orderByDesc(BusinessIndicatorDO::getId));
}
default List<BusinessIndicatorDO> selectListByParentId(Long parentId) {
LambdaQueryWrapperX<BusinessIndicatorDO> queryWrapper = new LambdaQueryWrapperX<BusinessIndicatorDO>()
.orderByDesc(BusinessIndicatorDO::getId);
// 如果parentId 是 null查询根节点parentId 为 null 的节点)
if (parentId == null) {
queryWrapper.isNull(BusinessIndicatorDO::getParentId);
} else {
queryWrapper.eq(BusinessIndicatorDO::getParentId, parentId);
}
return selectList(queryWrapper);
}
}

View File

@@ -0,0 +1,27 @@
package com.zt.plat.module.base.dal.dao.businessrule;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.base.dal.dataobject.businessrule.BusinessRuleDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.base.controller.admin.businessrule.vo.*;
/**
* 业务规则 Mapper
*
* @author yangxiaofeng
*/
@Mapper
public interface BusinessRuleMapper extends BaseMapperX<BusinessRuleDO> {
default PageResult<BusinessRuleDO> selectPage(BusinessRulePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BusinessRuleDO>()
.eqIfPresent(BusinessRuleDO::getStatusValue, reqVO.getStatusValue())
.eqIfPresent(BusinessRuleDO::getTypeValue, reqVO.getTypeValue())
.eqIfPresent(BusinessRuleDO::getCode, reqVO.getCode())
.likeIfPresent(BusinessRuleDO::getName, reqVO.getName())
.orderByDesc(BusinessRuleDO::getId));
}
}

View File

@@ -0,0 +1,57 @@
package com.zt.plat.module.base.dal.dataobject.businessalgorithm;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
/**
* 业务算法 DO
*
* @author yangxiaofeng
*/
@TableName("bse_bsn_alg")
@KeySequence("bse_bsn_alg_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BusinessAlgorithmDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 类型
*/
@TableField("TP_VAL")
private String typeValue;
/**
* 状态
*/
@TableField("STS_VAL")
private String statusValue;
/**
* 算法编码
*/
@TableField("CD")
private String code;
/**
* 算法名称
*/
@TableField("NAME")
private String name;
/**
* 算法描述
*/
@TableField("DSP")
private String description;
/**
* 算法代码
*/
@TableField("CDG")
private String coding;
}

View File

@@ -0,0 +1,78 @@
package com.zt.plat.module.base.dal.dataobject.businessdepartmentindicator;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
/**
* 部门持有指标 DO
*
* @author YangXiaofeng
*/
@TableName("bse_bsn_dept_ind")
@KeySequence("bse_bsn_dept_ind_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
/**
* 支持业务基类继承isBusiness=true 时继承 BusinessBaseDO否则继承 BaseDO
*/
public class BusinessDepartmentIndicatorDO extends BusinessBaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 指标ID
*/
@TableField("IND_ID")
private Long indicatorId;
/**
* 计量单位ID
*/
@TableField("UNT_ID")
private Long unitId;
/**
* 规则ID
*/
@TableField("RUL_ID")
private Long ruleId;
/**
* 算法ID
*/
@TableField("ALG_ID")
private Long algorithmId;
/**
* 实体ID
*/
@TableField("ENTY_ID")
private Long entityId;
/**
* 值
*/
@TableField("VAL")
private String value;
/**
* 是否关键指标
*/
@TableField("IS_KY")
private Integer isKey;
/**
* 排序号
*/
@TableField("SRT")
private Long sort;
/**
* 备注
*/
@TableField("RMK")
private String remark;
}

View File

@@ -0,0 +1,63 @@
package com.zt.plat.module.base.dal.dataobject.businessdictionarytype;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
/**
* 业务字典数据 DO
*
* @author yangxiaofeng
*/
@TableName("bse_bsn_dic_dat")
@KeySequence("bse_bsn_dic_dat_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BusinessDictionaryDataDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 上级字典
*/
@TableField("PRN_ID")
private Long parentId;
/**
* 字典类型
*/
@TableField("DIC_TP_ID")
private Long dictionaryTypeId;
/**
* 排序号
*/
@TableField("SRT")
private Long sort;
/**
* 字典标签
*/
@TableField("LBL")
private String label;
/**
* 字典值
*/
@TableField("VAL")
private String value;
/**
* 状态(0正常 1停用)
*/
@TableField("STS")
private Long status;
/**
* 备注
*/
@TableField("RMK")
private String remark;
}

View File

@@ -0,0 +1,60 @@
package com.zt.plat.module.base.dal.dataobject.businessdictionarytype;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
/**
* 业务字典类型 DO
*
* @author 后台管理
*/
@TableName("bse_bsn_dic_tp")
@KeySequence("bse_bsn_dic_tp_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
/**
* 支持业务基类继承isBusiness=true 时继承 BusinessBaseDO否则继承 BaseDO
*/
public class BusinessDictionaryTypeDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 字典名称
*/
@TableField("NAME")
private String name;
/**
* 字典类型
*/
@TableField("TP")
private String type;
/**
* 状态(0正常 1停用)
*/
@TableField("STS")
private Long status;
/**
* 备注
*/
@TableField("RMK")
private String remark;
/**
* 删除时间
*/
@TableField("DEL_TM")
private LocalDateTime delTime;
}

View File

@@ -0,0 +1,54 @@
package com.zt.plat.module.base.dal.dataobject.businessdimension;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
/**
* 经营指标维度 DO
*
* @author 陈鹏
*/
@TableName("bse_bsn_dim")
@KeySequence("bse_bsn_dim_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BusinessDimensionDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 父级ID
*/
@TableField("PRN_ID")
private Long parentId;
/**
* 维度类型
*/
@TableField("TP_VAL")
private String typeValue;
/**
* 维度编码
*/
@TableField("CD")
private String code;
/**
* 维度名称
*/
@TableField("NAME")
private String name;
/**
* 备注
*/
@TableField("RMK")
private String remark;
}

View File

@@ -0,0 +1,99 @@
package com.zt.plat.module.base.dal.dataobject.businessindicator;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
/**
* 经营指标 DO
*
* @author chengpeng
*/
@TableName("bse_bsn_ind")
@KeySequence("bse_bsn_ind_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BusinessIndicatorDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 父级ID
*/
@TableField("PRN_ID")
private Long parentId;
/**
* 指标编码
*/
@TableField("CD")
private String code;
/**
* 指标名称
*/
@TableField("NAME")
private String name;
/**
* 指标描述
*/
@TableField("DSP")
private String description;
/**
* 数据类型
*/
@TableField("DAT_VAL")
private String dataValue;
/**
* 计量单位量ID
*/
@TableField("QTY_ID")
private Long quantityId;
/**
* 计量单位ID
*/
@TableField("UNT_ID")
private Long unitId;
/**
* 算法ID
*/
@TableField("ALG_ID")
private Long algorithmId;
/**
* 规则ID
*/
@TableField("RUL_ID")
private Long ruleId;
/**
* 维度ID
*/
@TableField("DIM_ID")
private Long dimensionId;
/**
* 周期类型值
*/
@TableField("CYCL_VAL")
private String cycleValue;
/**
* 状态
*/
@TableField("STS_VAL")
private String statusValue;
/**
* 是否可修改
*/
@TableField("IS_MDF")
private Integer isModify;
/**
* 用户ID
*/
@TableField("USER_ID")
private Long userId;
}

View File

@@ -0,0 +1,60 @@
package com.zt.plat.module.base.dal.dataobject.businessrule;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
/**
* 业务规则 DO
*
* @author yangxiaofeng
*/
@TableName("bse_bsn_rul")
@KeySequence("bse_bsn_rul_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BusinessRuleDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 状态
*/
@TableField("STS_VAL")
private String statusValue;
/**
* 类型
*/
@TableField("TP_VAL")
private String typeValue;
/**
* 规则编码
*/
@TableField("CD")
private String code;
/**
* 规则名称
*/
@TableField("NAME")
private String name;
/**
* 规则描述
*/
@TableField("DSP")
private String description;
/**
* 规则表达式
*/
@TableField("EPSSN")
private String expression;
}

View File

@@ -0,0 +1,61 @@
package com.zt.plat.module.base.service.businessalgorithm;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.base.controller.admin.businessalgorithm.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessalgorithm.BusinessAlgorithmDO;
import com.zt.plat.framework.common.pojo.PageResult;
/**
* 业务算法 Service 接口
*
* @author yangxiaofeng
*/
public interface BusinessAlgorithmService {
/**
* 创建业务算法
*
* @param createReqVO 创建信息
* @return 编号
*/
BusinessAlgorithmRespVO createBusinessAlgorithm(@Valid BusinessAlgorithmSaveReqVO createReqVO);
/**
* 更新业务算法
*
* @param updateReqVO 更新信息
*/
void updateBusinessAlgorithm(@Valid BusinessAlgorithmSaveReqVO updateReqVO);
/**
* 删除业务算法
*
* @param id 编号
*/
void deleteBusinessAlgorithm(Long id);
/**
* 批量删除业务算法
*
* @param ids 编号
*/
void deleteBusinessAlgorithmListByIds(List<Long> ids);
/**
* 获得业务算法
*
* @param id 编号
* @return 业务算法
*/
BusinessAlgorithmDO getBusinessAlgorithm(Long id);
/**
* 获得业务算法分页
*
* @param pageReqVO 分页查询
* @return 业务算法分页
*/
PageResult<BusinessAlgorithmDO> getBusinessAlgorithmPage(BusinessAlgorithmPageReqVO pageReqVO);
}

View File

@@ -0,0 +1,85 @@
package com.zt.plat.module.base.service.businessalgorithm;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import com.zt.plat.module.base.controller.admin.businessalgorithm.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessalgorithm.BusinessAlgorithmDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.base.dal.dao.businessalgorithm.BusinessAlgorithmMapper;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
/**
* 业务算法 Service 实现类
*
* @author yangxiaofeng
*/
@Service
@Validated
public class BusinessAlgorithmServiceImpl implements BusinessAlgorithmService {
@Resource
private BusinessAlgorithmMapper businessAlgorithmMapper;
@Override
public BusinessAlgorithmRespVO createBusinessAlgorithm(BusinessAlgorithmSaveReqVO createReqVO) {
// 插入
BusinessAlgorithmDO businessAlgorithm = BeanUtils.toBean(createReqVO, BusinessAlgorithmDO.class);
businessAlgorithmMapper.insert(businessAlgorithm);
// 返回
return BeanUtils.toBean(businessAlgorithm, BusinessAlgorithmRespVO.class);
}
@Override
public void updateBusinessAlgorithm(BusinessAlgorithmSaveReqVO updateReqVO) {
// 校验存在
validateBusinessAlgorithmExists(updateReqVO.getId());
// 更新
BusinessAlgorithmDO updateObj = BeanUtils.toBean(updateReqVO, BusinessAlgorithmDO.class);
businessAlgorithmMapper.updateById(updateObj);
}
@Override
public void deleteBusinessAlgorithm(Long id) {
// 校验存在
validateBusinessAlgorithmExists(id);
// 删除
businessAlgorithmMapper.deleteById(id);
}
@Override
public void deleteBusinessAlgorithmListByIds(List<Long> ids) {
// 校验存在
validateBusinessAlgorithmExists(ids);
// 删除
businessAlgorithmMapper.deleteByIds(ids);
}
private void validateBusinessAlgorithmExists(List<Long> ids) {
List<BusinessAlgorithmDO> list = businessAlgorithmMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(BUSINESS_ALGORITHM_NOT_EXISTS);
}
}
private void validateBusinessAlgorithmExists(Long id) {
if (businessAlgorithmMapper.selectById(id) == null) {
throw exception(BUSINESS_ALGORITHM_NOT_EXISTS);
}
}
@Override
public BusinessAlgorithmDO getBusinessAlgorithm(Long id) {
return businessAlgorithmMapper.selectById(id);
}
@Override
public PageResult<BusinessAlgorithmDO> getBusinessAlgorithmPage(BusinessAlgorithmPageReqVO pageReqVO) {
return businessAlgorithmMapper.selectPage(pageReqVO);
}
}

View File

@@ -0,0 +1,61 @@
package com.zt.plat.module.base.service.businessdepartmentindicator;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.base.controller.admin.businessdepartmentindicator.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessdepartmentindicator.BusinessDepartmentIndicatorDO;
import com.zt.plat.framework.common.pojo.PageResult;
/**
* 部门持有指标 Service 接口
*
* @author YangXiaofeng
*/
public interface BusinessDepartmentIndicatorService {
/**
* 创建部门持有指标
*
* @param createReqVO 创建信息
* @return 编号
*/
BusinessDepartmentIndicatorRespVO createBusinessDepartmentIndicator(@Valid BusinessDepartmentIndicatorSaveReqVO createReqVO);
/**
* 更新部门持有指标
*
* @param updateReqVO 更新信息
*/
void updateBusinessDepartmentIndicator(@Valid BusinessDepartmentIndicatorSaveReqVO updateReqVO);
/**
* 删除部门持有指标
*
* @param id 编号
*/
void deleteBusinessDepartmentIndicator(Long id);
/**
* 批量删除部门持有指标
*
* @param ids 编号
*/
void deleteBusinessDepartmentIndicatorListByIds(List<Long> ids);
/**
* 获得部门持有指标
*
* @param id 编号
* @return 部门持有指标
*/
BusinessDepartmentIndicatorDO getBusinessDepartmentIndicator(Long id);
/**
* 获得部门持有指标分页
*
* @param pageReqVO 分页查询
* @return 部门持有指标分页
*/
PageResult<BusinessDepartmentIndicatorDO> getBusinessDepartmentIndicatorPage(BusinessDepartmentIndicatorPageReqVO pageReqVO);
}

View File

@@ -0,0 +1,88 @@
package com.zt.plat.module.base.service.businessdepartmentindicator;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import com.zt.plat.module.base.controller.admin.businessdepartmentindicator.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessdepartmentindicator.BusinessDepartmentIndicatorDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.base.dal.dao.businessdepartmentindicator.BusinessDepartmentIndicatorMapper;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
/**
* 部门持有指标 Service 实现类
*
* @author YangXiaofeng
*/
@Service
@Validated
public class BusinessDepartmentIndicatorServiceImpl implements BusinessDepartmentIndicatorService {
@Resource
private BusinessDepartmentIndicatorMapper businessDepartmentIndicatorMapper;
@Override
public BusinessDepartmentIndicatorRespVO createBusinessDepartmentIndicator(BusinessDepartmentIndicatorSaveReqVO createReqVO) {
// 插入
BusinessDepartmentIndicatorDO businessDepartmentIndicator = BeanUtils.toBean(createReqVO, BusinessDepartmentIndicatorDO.class);
businessDepartmentIndicatorMapper.insert(businessDepartmentIndicator);
// 返回
return BeanUtils.toBean(businessDepartmentIndicator, BusinessDepartmentIndicatorRespVO.class);
}
@Override
public void updateBusinessDepartmentIndicator(BusinessDepartmentIndicatorSaveReqVO updateReqVO) {
// 校验存在
validateBusinessDepartmentIndicatorExists(updateReqVO.getId());
// 更新
BusinessDepartmentIndicatorDO updateObj = BeanUtils.toBean(updateReqVO, BusinessDepartmentIndicatorDO.class);
businessDepartmentIndicatorMapper.updateById(updateObj);
}
@Override
public void deleteBusinessDepartmentIndicator(Long id) {
// 校验存在
validateBusinessDepartmentIndicatorExists(id);
// 删除
businessDepartmentIndicatorMapper.deleteById(id);
}
@Override
public void deleteBusinessDepartmentIndicatorListByIds(List<Long> ids) {
// 校验存在
validateBusinessDepartmentIndicatorExists(ids);
// 删除
businessDepartmentIndicatorMapper.deleteByIds(ids);
}
private void validateBusinessDepartmentIndicatorExists(List<Long> ids) {
List<BusinessDepartmentIndicatorDO> list = businessDepartmentIndicatorMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(BUSINESS_DEPARTMENT_INDICATOR_NOT_EXISTS);
}
}
private void validateBusinessDepartmentIndicatorExists(Long id) {
if (businessDepartmentIndicatorMapper.selectById(id) == null) {
throw exception(BUSINESS_DEPARTMENT_INDICATOR_NOT_EXISTS);
}
}
@Override
public BusinessDepartmentIndicatorDO getBusinessDepartmentIndicator(Long id) {
return businessDepartmentIndicatorMapper.selectById(id);
}
@Override
public PageResult<BusinessDepartmentIndicatorDO> getBusinessDepartmentIndicatorPage(BusinessDepartmentIndicatorPageReqVO pageReqVO) {
return businessDepartmentIndicatorMapper.selectPage(pageReqVO);
}
}

View File

@@ -0,0 +1,72 @@
package com.zt.plat.module.base.service.businessdictionarytype;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryTypeDO;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
import com.zt.plat.framework.common.pojo.PageResult;
/**
* 业务字典类型 Service 接口
*
* @author 后台管理
*/
public interface BusinessDictionaryTypeService {
/**
* 创建业务字典类型
*
* @param createReqVO 创建信息
* @return 编号
*/
BusinessDictionaryTypeRespVO createBusinessDictionaryType(@Valid BusinessDictionaryTypeSaveReqVO createReqVO);
/**
* 更新业务字典类型
*
* @param updateReqVO 更新信息
*/
void updateBusinessDictionaryType(@Valid BusinessDictionaryTypeSaveReqVO updateReqVO);
/**
* 删除业务字典类型
*
* @param id 编号
*/
void deleteBusinessDictionaryType(Long id);
/**
* 批量删除业务字典类型
*
* @param ids 编号
*/
void deleteBusinessDictionaryTypeListByIds(List<Long> ids);
/**
* 获得业务字典类型
*
* @param id 编号
* @return 业务字典类型
*/
BusinessDictionaryTypeDO getBusinessDictionaryType(Long id);
/**
* 获得业务字典类型分页
*
* @param pageReqVO 分页查询
* @return 业务字典类型分页
*/
PageResult<BusinessDictionaryTypeDO> getBusinessDictionaryTypePage(BusinessDictionaryTypePageReqVO pageReqVO);
// ==================== 子表(业务字典数据) ====================
/**
* 获得业务字典数据列表
*
* @param dictionaryTypeId 字典类型
* @return 业务字典数据列表
*/
List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByDictionaryTypeId(Long dictionaryTypeId);
}

View File

@@ -0,0 +1,155 @@
package com.zt.plat.module.base.service.businessdictionarytype;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.zt.plat.module.base.controller.admin.businessdictionarytype.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryTypeDO;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.base.dal.dao.businessdictionarytype.BusinessDictionaryTypeMapper;
import com.zt.plat.module.base.dal.dao.businessdictionarytype.BusinessDictionaryDataMapper;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
import static com.zt.plat.framework.common.util.collection.CollectionUtils.diffList;
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
/**
* 业务字典类型 Service 实现类
*
* @author 后台管理
*/
@Service
@Validated
public class BusinessDictionaryTypeServiceImpl implements BusinessDictionaryTypeService {
@Resource
private BusinessDictionaryTypeMapper businessDictionaryTypeMapper;
@Resource
private BusinessDictionaryDataMapper businessDictionaryDataMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public BusinessDictionaryTypeRespVO createBusinessDictionaryType(BusinessDictionaryTypeSaveReqVO createReqVO) {
// 插入
BusinessDictionaryTypeDO businessDictionaryType = BeanUtils.toBean(createReqVO, BusinessDictionaryTypeDO.class);
businessDictionaryTypeMapper.insert(businessDictionaryType);
// 插入子表
createBusinessDictionaryDataList(businessDictionaryType.getId(), createReqVO.getBusinessDictionaryDatas());
// 返回
return BeanUtils.toBean(businessDictionaryType, BusinessDictionaryTypeRespVO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateBusinessDictionaryType(BusinessDictionaryTypeSaveReqVO updateReqVO) {
// 校验存在
validateBusinessDictionaryTypeExists(updateReqVO.getId());
// 更新
BusinessDictionaryTypeDO updateObj = BeanUtils.toBean(updateReqVO, BusinessDictionaryTypeDO.class);
businessDictionaryTypeMapper.updateById(updateObj);
// 更新子表
updateBusinessDictionaryDataList(updateReqVO.getId(), updateReqVO.getBusinessDictionaryDatas());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteBusinessDictionaryType(Long id) {
// 校验存在
validateBusinessDictionaryTypeExists(id);
// 删除
businessDictionaryTypeMapper.deleteById(id);
// 删除子表
deleteBusinessDictionaryDataByDictionaryTypeId(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteBusinessDictionaryTypeListByIds(List<Long> ids) {
// 校验存在
validateBusinessDictionaryTypeExists(ids);
// 删除
businessDictionaryTypeMapper.deleteByIds(ids);
// 删除子表
deleteBusinessDictionaryDataByDictionaryTypeIds(ids);
}
private void validateBusinessDictionaryTypeExists(List<Long> ids) {
List<BusinessDictionaryTypeDO> list = businessDictionaryTypeMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(BUSINESS_DICTIONARY_TYPE_NOT_EXISTS);
}
}
private void validateBusinessDictionaryTypeExists(Long id) {
if (businessDictionaryTypeMapper.selectById(id) == null) {
throw exception(BUSINESS_DICTIONARY_TYPE_NOT_EXISTS);
}
}
@Override
public BusinessDictionaryTypeDO getBusinessDictionaryType(Long id) {
return businessDictionaryTypeMapper.selectById(id);
}
@Override
public PageResult<BusinessDictionaryTypeDO> getBusinessDictionaryTypePage(BusinessDictionaryTypePageReqVO pageReqVO) {
return businessDictionaryTypeMapper.selectPage(pageReqVO);
}
// ==================== 子表(业务字典数据) ====================
@Override
public List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByDictionaryTypeId(Long dictionaryTypeId) {
return businessDictionaryDataMapper.selectListByDictionaryTypeId(dictionaryTypeId);
}
private void createBusinessDictionaryDataList(Long dictionaryTypeId, List<BusinessDictionaryDataDO> list) {
list.forEach(o -> o.setDictionaryTypeId(dictionaryTypeId).clean());
businessDictionaryDataMapper.insertBatch(list);
}
private void updateBusinessDictionaryDataList(Long dictionaryTypeId, List<BusinessDictionaryDataDO> list) {
list.forEach(o -> o.setDictionaryTypeId(dictionaryTypeId).clean());
List<BusinessDictionaryDataDO> oldList = businessDictionaryDataMapper.selectListByDictionaryTypeId(dictionaryTypeId);
List<List<BusinessDictionaryDataDO>> diffList = diffList(oldList, list, (oldVal, newVal) -> {
boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId());
if (same) {
newVal.setId(oldVal.getId()).clean(); // 解决更新情况下updateTime 不更新
}
return same;
});
// 第二步,批量添加、修改、删除
if (CollUtil.isNotEmpty(diffList.get(0))) {
businessDictionaryDataMapper.insertBatch(diffList.get(0));
}
if (CollUtil.isNotEmpty(diffList.get(1))) {
businessDictionaryDataMapper.updateBatch(diffList.get(1));
}
if (CollUtil.isNotEmpty(diffList.get(2))) {
businessDictionaryDataMapper.deleteByIds(convertList(diffList.get(2), BusinessDictionaryDataDO::getId));
}
}
private void deleteBusinessDictionaryDataByDictionaryTypeId(Long dictionaryTypeId) {
businessDictionaryDataMapper.deleteByDictionaryTypeId(dictionaryTypeId);
}
private void deleteBusinessDictionaryDataByDictionaryTypeIds(List<Long> dictionaryTypeIds) {
businessDictionaryDataMapper.deleteByDictionaryTypeIds(dictionaryTypeIds);
}
}

View File

@@ -0,0 +1,69 @@
package com.zt.plat.module.base.service.businessdimension;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.base.controller.admin.businessdimension.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessdimension.BusinessDimensionDO;
import com.zt.plat.framework.common.pojo.PageResult;
/**
* 经营指标维度 Service 接口
*
* @author 陈鹏
*/
public interface BusinessDimensionService {
/**
* 创建经营指标维度
*
* @param createReqVO 创建信息
* @return 编号
*/
BusinessDimensionRespVO createBusinessDimension(@Valid BusinessDimensionSaveReqVO createReqVO);
/**
* 更新经营指标维度
*
* @param updateReqVO 更新信息
*/
void updateBusinessDimension(@Valid BusinessDimensionSaveReqVO updateReqVO);
/**
* 删除经营指标维度
*
* @param id 编号
*/
void deleteBusinessDimension(Long id);
/**
* 批量删除经营指标维度
*
* @param ids 编号
*/
void deleteBusinessDimensionListByIds(List<Long> ids);
/**
* 获得经营指标维度
*
* @param id 编号
* @return 经营指标维度
*/
BusinessDimensionDO getBusinessDimension(Long id);
/**
* 获得经营指标维度分页
*
* @param pageReqVO 分页查询
* @return 经营指标维度分页
*/
PageResult<BusinessDimensionDO> getBusinessDimensionPage(BusinessDimensionPageReqVO pageReqVO);
/**
* 根据父级ID获取经营指标维度列表
*
* @param parentId 父级ID
* @return 经营指标维度列表
*/
List<BusinessDimensionDO> getBusinessDimensionListByParentId(Long parentId, Integer level);
}

View File

@@ -0,0 +1,90 @@
package com.zt.plat.module.base.service.businessdimension;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import com.zt.plat.module.base.controller.admin.businessdimension.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessdimension.BusinessDimensionDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.base.dal.dao.businessdimension.BusinessDimensionMapper;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
/**
* 经营指标维度 Service 实现类
*
* @author 陈鹏
*/
@Service
@Validated
public class BusinessDimensionServiceImpl implements BusinessDimensionService {
@Resource
private BusinessDimensionMapper businessDimensionMapper;
@Override
public BusinessDimensionRespVO createBusinessDimension(BusinessDimensionSaveReqVO createReqVO) {
// 插入
BusinessDimensionDO businessDimension = BeanUtils.toBean(createReqVO, BusinessDimensionDO.class);
businessDimensionMapper.insert(businessDimension);
// 返回
return BeanUtils.toBean(businessDimension, BusinessDimensionRespVO.class);
}
@Override
public void updateBusinessDimension(BusinessDimensionSaveReqVO updateReqVO) {
// 校验存在
validateBusinessDimensionExists(updateReqVO.getId());
// 更新
BusinessDimensionDO updateObj = BeanUtils.toBean(updateReqVO, BusinessDimensionDO.class);
businessDimensionMapper.updateById(updateObj);
}
@Override
public void deleteBusinessDimension(Long id) {
// 校验存在
validateBusinessDimensionExists(id);
// 删除
businessDimensionMapper.deleteById(id);
}
@Override
public void deleteBusinessDimensionListByIds(List<Long> ids) {
// 校验存在
validateBusinessDimensionExists(ids);
// 删除
businessDimensionMapper.deleteByIds(ids);
}
private void validateBusinessDimensionExists(List<Long> ids) {
List<BusinessDimensionDO> list = businessDimensionMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(BUSINESS_DIMENSION_NOT_EXISTS);
}
}
private void validateBusinessDimensionExists(Long id) {
if (businessDimensionMapper.selectById(id) == null) {
throw exception(BUSINESS_DIMENSION_NOT_EXISTS);
}
}
@Override
public BusinessDimensionDO getBusinessDimension(Long id) {
return businessDimensionMapper.selectById(id);
}
@Override
public PageResult<BusinessDimensionDO> getBusinessDimensionPage(BusinessDimensionPageReqVO pageReqVO) {
return businessDimensionMapper.selectPage(pageReqVO);
}
@Override
public List<BusinessDimensionDO> getBusinessDimensionListByParentId(Long parentId, Integer level) {
return businessDimensionMapper.selectListByParentId(parentId, level);
}
}

View File

@@ -0,0 +1,77 @@
package com.zt.plat.module.base.service.businessindicator;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.base.controller.admin.businessindicator.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessindicator.BusinessIndicatorDO;
import com.zt.plat.framework.common.pojo.PageResult;
/**
* 经营指标 Service 接口
*
* @author chengpeng
*/
public interface BusinessIndicatorService {
/**
* 创建经营指标
*
* @param createReqVO 创建信息
* @return 编号
*/
BusinessIndicatorRespVO createBusinessIndicator(@Valid BusinessIndicatorSaveReqVO createReqVO);
/**
* 更新经营指标
*
* @param updateReqVO 更新信息
*/
void updateBusinessIndicator(@Valid BusinessIndicatorSaveReqVO updateReqVO);
/**
* 删除经营指标
*
* @param id 编号
*/
void deleteBusinessIndicator(Long id);
/**
* 批量删除经营指标
*
* @param ids 编号
*/
void deleteBusinessIndicatorListByIds(List<Long> ids);
/**
* 获得经营指标
*
* @param id 编号
* @return 经营指标
*/
BusinessIndicatorDO getBusinessIndicator(Long id);
/**
* 获得经营指标分页
*
* @param pageReqVO 分页查询
* @return 经营指标分页
*/
PageResult<BusinessIndicatorDO> getBusinessIndicatorPage(BusinessIndicatorPageReqVO pageReqVO);
/**
* 获得经营指标分页(包含关联信息)
*
* @param pageReqVO 分页查询
* @return 经营指标分页(包含算法模型类型、算法类型、规则类型、规则模型、负责人相关名称信息)
*/
PageResult<BusinessIndicatorRespVO> getBusinessIndicatorPageWithRelations(BusinessIndicatorPageReqVO pageReqVO);
/**
* 根据父级ID获取经营指标列表
*
* @param parentId 父级ID
* @return 经营指标列表
*/
List<BusinessIndicatorDO> getBusinessIndicatorListByParentId(Long parentId);
}

View File

@@ -0,0 +1,183 @@
package com.zt.plat.module.base.service.businessindicator;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import com.zt.plat.module.base.controller.admin.businessindicator.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessindicator.BusinessIndicatorDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.base.dal.dao.businessindicator.BusinessIndicatorMapper;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
import com.zt.plat.module.base.dal.dataobject.businessalgorithm.BusinessAlgorithmDO;
import com.zt.plat.module.base.dal.dataobject.businessrule.BusinessRuleDO;
import com.zt.plat.module.base.dal.dao.businessalgorithm.BusinessAlgorithmMapper;
import com.zt.plat.module.base.dal.dao.businessrule.BusinessRuleMapper;
import com.zt.plat.module.system.api.user.AdminUserApi;
import com.zt.plat.module.system.api.user.dto.AdminUserRespDTO;
/**
* 经营指标 Service 实现类
*
* @author chengpeng
*/
@Service
@Validated
public class BusinessIndicatorServiceImpl implements BusinessIndicatorService {
@Resource
private BusinessIndicatorMapper businessIndicatorMapper;
@Resource
private BusinessAlgorithmMapper businessAlgorithmMapper;
@Resource
private BusinessRuleMapper businessRuleMapper;
@Resource
private AdminUserApi adminUserApi;
@Override
public BusinessIndicatorRespVO createBusinessIndicator(BusinessIndicatorSaveReqVO createReqVO) {
// 插入
BusinessIndicatorDO businessIndicator = BeanUtils.toBean(createReqVO, BusinessIndicatorDO.class);
businessIndicatorMapper.insert(businessIndicator);
// 返回
return BeanUtils.toBean(businessIndicator, BusinessIndicatorRespVO.class);
}
@Override
public void updateBusinessIndicator(BusinessIndicatorSaveReqVO updateReqVO) {
// 校验存在
validateBusinessIndicatorExists(updateReqVO.getId());
// 更新
BusinessIndicatorDO updateObj = BeanUtils.toBean(updateReqVO, BusinessIndicatorDO.class);
businessIndicatorMapper.updateById(updateObj);
}
@Override
public void deleteBusinessIndicator(Long id) {
// 校验存在
validateBusinessIndicatorExists(id);
// 删除
businessIndicatorMapper.deleteById(id);
}
@Override
public void deleteBusinessIndicatorListByIds(List<Long> ids) {
// 校验存在
validateBusinessIndicatorExists(ids);
// 删除
businessIndicatorMapper.deleteByIds(ids);
}
private void validateBusinessIndicatorExists(List<Long> ids) {
List<BusinessIndicatorDO> list = businessIndicatorMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(BUSINESS_INDICATOR_NOT_EXISTS);
}
}
private void validateBusinessIndicatorExists(Long id) {
if (businessIndicatorMapper.selectById(id) == null) {
throw exception(BUSINESS_INDICATOR_NOT_EXISTS);
}
}
@Override
public BusinessIndicatorDO getBusinessIndicator(Long id) {
return businessIndicatorMapper.selectById(id);
}
@Override
public PageResult<BusinessIndicatorDO> getBusinessIndicatorPage(BusinessIndicatorPageReqVO pageReqVO) {
return businessIndicatorMapper.selectPage(pageReqVO);
}
@Override
public PageResult<BusinessIndicatorRespVO> getBusinessIndicatorPageWithRelations(BusinessIndicatorPageReqVO pageReqVO) {
// 查询经营指标分页数据
PageResult<BusinessIndicatorDO> pageResult = businessIndicatorMapper.selectPage(pageReqVO);
// 转换为 VO 对象
List<BusinessIndicatorRespVO> voList = BeanUtils.toBean(pageResult.getList(), BusinessIndicatorRespVO.class);
// 收集需要关联查询的 ID 列表
Set<Long> algorithmIds = new HashSet<>();
Set<Long> ruleIds = new HashSet<>();
Set<Long> userIds = new HashSet<>();
for (BusinessIndicatorDO indicator : pageResult.getList()) {
if (indicator.getAlgorithmId() != null) {
algorithmIds.add(indicator.getAlgorithmId());
}
if (indicator.getRuleId() != null) {
ruleIds.add(indicator.getRuleId());
}
if (indicator.getUserId() != null) {
userIds.add(indicator.getUserId());
}
}
// 批量查询关联数据
List<BusinessAlgorithmDO> algorithms = algorithmIds.isEmpty() ? Collections.emptyList() :
businessAlgorithmMapper.selectBatchIds(algorithmIds);
List<BusinessRuleDO> rules = ruleIds.isEmpty() ? Collections.emptyList() :
businessRuleMapper.selectBatchIds(ruleIds);
Map<Long, AdminUserRespDTO> userMap = userIds.isEmpty() ? Collections.emptyMap() :
adminUserApi.getUserMap(userIds);
// 建立 ID 到对象的映射
Map<Long, BusinessAlgorithmDO> algorithmMap = new HashMap<>();
Map<Long, BusinessRuleDO> ruleMap = new HashMap<>();
for (BusinessAlgorithmDO algorithm : algorithms) {
algorithmMap.put(algorithm.getId(), algorithm);
}
for (BusinessRuleDO rule : rules) {
ruleMap.put(rule.getId(), rule);
}
// 填充关联信息
for (int i = 0; i < pageResult.getList().size(); i++) {
BusinessIndicatorDO indicator = pageResult.getList().get(i);
BusinessIndicatorRespVO vo = voList.get(i);
// 填充算法相关信息
if (indicator.getAlgorithmId() != null && algorithmMap.containsKey(indicator.getAlgorithmId())) {
BusinessAlgorithmDO algorithm = algorithmMap.get(indicator.getAlgorithmId());
vo.setAlgorithmName(algorithm.getName());
vo.setAlgorithmTypeValue(algorithm.getTypeValue());
}
// 填充规则相关信息
if (indicator.getRuleId() != null && ruleMap.containsKey(indicator.getRuleId())) {
BusinessRuleDO rule = ruleMap.get(indicator.getRuleId());
vo.setRuleName(rule.getName());
vo.setRuleTypeValue(rule.getTypeValue());
}
// 填充用户相关信息
if (indicator.getUserId() != null && userMap.containsKey(indicator.getUserId())) {
AdminUserRespDTO user = userMap.get(indicator.getUserId());
vo.setUserName(user.getNickname());
}
}
return new PageResult<>(voList, pageResult.getTotal());
}
@Override
public List<BusinessIndicatorDO> getBusinessIndicatorListByParentId(Long parentId) {
return businessIndicatorMapper.selectListByParentId(parentId);
}
}

View File

@@ -0,0 +1,61 @@
package com.zt.plat.module.base.service.businessrule;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.base.controller.admin.businessrule.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessrule.BusinessRuleDO;
import com.zt.plat.framework.common.pojo.PageResult;
/**
* 业务规则 Service 接口
*
* @author yangxiaofeng
*/
public interface BusinessRuleService {
/**
* 创建业务规则
*
* @param createReqVO 创建信息
* @return 编号
*/
BusinessRuleRespVO createBusinessRule(@Valid BusinessRuleSaveReqVO createReqVO);
/**
* 更新业务规则
*
* @param updateReqVO 更新信息
*/
void updateBusinessRule(@Valid BusinessRuleSaveReqVO updateReqVO);
/**
* 删除业务规则
*
* @param id 编号
*/
void deleteBusinessRule(Long id);
/**
* 批量删除业务规则
*
* @param ids 编号
*/
void deleteBusinessRuleListByIds(List<Long> ids);
/**
* 获得业务规则
*
* @param id 编号
* @return 业务规则
*/
BusinessRuleDO getBusinessRule(Long id);
/**
* 获得业务规则分页
*
* @param pageReqVO 分页查询
* @return 业务规则分页
*/
PageResult<BusinessRuleDO> getBusinessRulePage(BusinessRulePageReqVO pageReqVO);
}

View File

@@ -0,0 +1,88 @@
package com.zt.plat.module.base.service.businessrule;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import com.zt.plat.module.base.controller.admin.businessrule.vo.*;
import com.zt.plat.module.base.dal.dataobject.businessrule.BusinessRuleDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.base.dal.dao.businessrule.BusinessRuleMapper;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
/**
* 业务规则 Service 实现类
*
* @author yangxiaofeng
*/
@Service
@Validated
public class BusinessRuleServiceImpl implements BusinessRuleService {
@Resource
private BusinessRuleMapper businessRuleMapper;
@Override
public BusinessRuleRespVO createBusinessRule(BusinessRuleSaveReqVO createReqVO) {
// 插入
BusinessRuleDO businessRule = BeanUtils.toBean(createReqVO, BusinessRuleDO.class);
businessRuleMapper.insert(businessRule);
// 返回
return BeanUtils.toBean(businessRule, BusinessRuleRespVO.class);
}
@Override
public void updateBusinessRule(BusinessRuleSaveReqVO updateReqVO) {
// 校验存在
validateBusinessRuleExists(updateReqVO.getId());
// 更新
BusinessRuleDO updateObj = BeanUtils.toBean(updateReqVO, BusinessRuleDO.class);
businessRuleMapper.updateById(updateObj);
}
@Override
public void deleteBusinessRule(Long id) {
// 校验存在
validateBusinessRuleExists(id);
// 删除
businessRuleMapper.deleteById(id);
}
@Override
public void deleteBusinessRuleListByIds(List<Long> ids) {
// 校验存在
validateBusinessRuleExists(ids);
// 删除
businessRuleMapper.deleteByIds(ids);
}
private void validateBusinessRuleExists(List<Long> ids) {
List<BusinessRuleDO> list = businessRuleMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(BUSINESS_RULE_NOT_EXISTS);
}
}
private void validateBusinessRuleExists(Long id) {
if (businessRuleMapper.selectById(id) == null) {
throw exception(BUSINESS_RULE_NOT_EXISTS);
}
}
@Override
public BusinessRuleDO getBusinessRule(Long id) {
return businessRuleMapper.selectById(id);
}
@Override
public PageResult<BusinessRuleDO> getBusinessRulePage(BusinessRulePageReqVO pageReqVO) {
return businessRuleMapper.selectPage(pageReqVO);
}
}

View File

@@ -0,0 +1,76 @@
<configuration>
<!-- 引用 Spring Boot 的 logback 基础配置 -->
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<!-- 变量 yudao.info.base-package基础业务包 -->
<springProperty scope="context" name="yudao.info.base-package" source="yudao.info.base-package"/>
<!-- 格式化输出:%d 表示日期,%X{tid} SkWalking 链路追踪编号,%thread 表示线程名,%-5level级别从左显示 5 个字符宽度,%msg日志消息%n是换行符 -->
<property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} | %highlight(${LOG_LEVEL_PATTERN:-%5p} ${PID:- }) | %boldYellow(%thread [%tid]) %boldGreen(%-40.40logger{39}) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
<!-- 控制台 Appender -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">     
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${PATTERN_DEFAULT}</pattern>
</layout>
</encoder>
</appender>
<!-- 文件 Appender -->
<!-- 参考 Spring Boot 的 file-appender.xml 编写 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${PATTERN_DEFAULT}</pattern>
</layout>
</encoder>
<!-- 日志文件名 -->
<file>${LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 滚动后的日志文件名 -->
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
<!-- 启动服务时,是否清理历史日志,一般不建议清理 -->
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
<!-- 日志文件,到达多少容量,进行滚动 -->
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
<!-- 日志文件的总大小0 表示不限制 -->
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
<!-- 日志文件的保留天数 -->
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30}</maxHistory>
</rollingPolicy>
</appender>
<!-- 异步写入日志,提升性能 -->
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志。默认的,如果队列的 80% 已满,则会丢弃 TRACT、DEBUG、INFO 级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能。默认值为 256 -->
<queueSize>256</queueSize>
<appender-ref ref="FILE"/>
</appender>
<!-- SkyWalking GRPC 日志收集实现日志中心。注意SkyWalking 8.4.0 版本开始支持 -->
<appender name="GRPC" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${PATTERN_DEFAULT}</pattern>
</layout>
</encoder>
</appender>
<!-- 本地环境 -->
<springProfile name="local">
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="GRPC"/> <!-- 本地环境下,如果不想接入 SkyWalking 日志服务,可以注释掉本行 -->
<appender-ref ref="ASYNC"/> <!-- 本地环境下,如果不想打印日志,可以注释掉本行 -->
</root>
</springProfile>
<!-- 其它环境 -->
<springProfile name="dev,test,stage,prod,default">
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="ASYNC"/>
<appender-ref ref="GRPC"/>
</root>
</springProfile>
</configuration>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -16,6 +16,9 @@ public class DeductRespDTO {
@Schema(description = "条款主键")
private Long formulaId;
@Schema(description = "金属元素缩写")
private String elementAbbreviation;
@Schema(description = "数据项类型(字典:GRD_CFG_TP)")
private String configType;
@@ -25,6 +28,18 @@ public class DeductRespDTO {
@Schema(description = "调整价")
private BigDecimal gradeAmount;
@Schema(description = "区间方式(字典STLM_RNG_WY)")
private String rangeWay;
@Schema(description = "上限")
private String up;
@Schema(description = "下限")
private String down;
@Schema(description = "类型(字典STLM_COEF)")
private String type;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@@ -25,4 +25,5 @@ public interface ErrorCodeConstants {
ErrorCode CONTRACT_STATUS_NOT_DELETE = new ErrorCode(1_027_000_010, "{}状态合同不允许删除");
ErrorCode CONTRACT_ERP_RCV_DLVY_NOT_EXISTS = new ErrorCode(1_027_000_011, "不存在的收支类型或收支类型为空");
ErrorCode CONTRACT_STATUS_NOT_ARCHIVE = new ErrorCode(1_027_000_012, "{}状态合同不允许归档");
ErrorCode CONTRACT_STATUS_NOT_SUBMIT_ERP = new ErrorCode(1_027_000_013, "{}状态合同不允许提交ERP");
}

View File

@@ -5,6 +5,11 @@ package com.zt.plat.module.contractorder.enums.contract;
*/
public enum DictEnum {
/** ERP请求状态 */
ERP_REQ_STS_RLBK("失败","RLBK",null),
ERP_REQ_STS_RCVG("执行中","RCVG",null),
ERP_REQ_STS_FIND("成功","FIND",null),
ERP_REQ_STS_WAIT("待上传","WAIT",null),
/** 业务关联类型 */
BSE_SYS_REL_TP_ORDER("订单","ORDER",null),
BSE_SYS_REL_TP_CONTRACT("合同","CONTRACT",null),

View File

@@ -135,18 +135,17 @@ public class ContractController implements BusinessControllerMarker {
return success(contractService.submitApproval(id));
}
// TODO
@PostMapping("/approval")
@Operation(summary = "合同审批 TODO")
@Operation(summary = "合同审批")
@PreAuthorize("@ss.hasPermission('base:contract:approval')")
public CommonResult<String> approval(@Valid @RequestBody ApprovalReqVO reqVO) {
public CommonResult<Boolean> approval(@Valid @RequestBody ApprovalReqVO reqVO) {
return success(contractService.approval(reqVO));
}
@PostMapping("/submit/erp")
@Operation(summary = "提交ERP")
@PreAuthorize("@ss.hasPermission('base:contract:erp')")
public CommonResult<List<String>> submitErp(@RequestBody List<Long> ids) {
public CommonResult<Boolean> submitErp(@RequestBody List<Long> ids) {
return success(contractService.submitErp(ids));
}

View File

@@ -13,11 +13,11 @@ public class ApprovalReqVO {
@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;
@Schema(description = "状态:待推送 WAIT_PUSH已驳回 REJECTED", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "审核状态不能为空")
private String status;
}

View File

@@ -15,6 +15,9 @@ public class DeductRespVO {
@Schema(description = "条款主键")
private Long formulaId;
@Schema(description = "金属元素缩写")
private String elementAbbreviation;
@Schema(description = "数据项类型(字典:GRD_CFG_TP)")
private String configType;
@@ -24,6 +27,18 @@ public class DeductRespVO {
@Schema(description = "调整价")
private BigDecimal gradeAmount;
@Schema(description = "区间方式(字典STLM_RNG_WY)")
private String rangeWay;
@Schema(description = "上限")
private String up;
@Schema(description = "下限")
private String down;
@Schema(description = "类型(字典STLM_COEF)")
private String type;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@@ -15,6 +15,9 @@ public class DeductSaveReqVO {
@Schema(description = "条款主键")
private Long formulaId;
@Schema(description = "金属元素缩写")
private String elementAbbreviation;
@Schema(description = "数据项类型(字典:GRD_CFG_TP)")
private String configType;
@@ -23,4 +26,16 @@ public class DeductSaveReqVO {
@Schema(description = "调整价")
private BigDecimal gradeAmount;
@Schema(description = "区间方式(字典STLM_RNG_WY)")
private String rangeWay;
@Schema(description = "上限")
private String up;
@Schema(description = "下限")
private String down;
@Schema(description = "类型(字典STLM_COEF)")
private String type;
}

View File

@@ -34,6 +34,11 @@ public class ContractDeductDO extends BusinessBaseDO {
*/
@TableField("FMU_ID")
private Long formulaId;
/**
* 金属元素缩写Cu\Au\Ag
*/
@TableField("ELEM_ABBR")
private String elementAbbreviation;
/**
* 数据项类型(字典:GRD_CFG_TP)
*/
@@ -49,4 +54,24 @@ public class ContractDeductDO extends BusinessBaseDO {
*/
@TableField("GRD_AMT")
private BigDecimal gradeAmount;
/**
* 区间方式(字典STLM_RNG_WY)
*/
@TableField("RNG_WY")
private String rangeWay;
/**
* 上限
*/
@TableField("UP")
private String up;
/**
* 下限
*/
@TableField("DOWN")
private String down;
/**
* 类型(字典STLM_COEF)
*/
@TableField("TP")
private String type;
}

View File

@@ -64,7 +64,7 @@ public interface ContractService {
* @param reqVO 审批信息
* @return 审批结果
*/
String approval(@Valid ApprovalReqVO reqVO);
Boolean approval(@Valid ApprovalReqVO reqVO);
/**
* 查询不计价规则列表
@@ -104,7 +104,7 @@ public interface ContractService {
* @param ids 合同ID集合
* @return
*/
List<String> submitErp(List<Long> ids);
Boolean submitErp(List<Long> ids);
/**
* 删除合同

View File

@@ -20,8 +20,8 @@ import com.zt.plat.module.base.dal.mysql.tmpltp.TmplInscBsnRelMapper;
import com.zt.plat.module.base.service.tmpltp.TemplateInstanceDataService;
import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
import com.zt.plat.module.bpm.api.task.BpmTaskApi;
import com.zt.plat.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
import com.zt.plat.module.bpm.api.task.dto.BpmTaskRespDTO;
import com.zt.plat.module.bpm.api.task.dto.*;
import com.zt.plat.module.bpm.enums.task.BpmProcessInstanceStatusEnum;
import com.zt.plat.module.contractorder.api.dto.contract.*;
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.*;
import com.zt.plat.module.contractorder.dal.dataobject.contract.*;
@@ -54,9 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayOutputStream;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -923,6 +921,7 @@ public class ContractServiceImpl implements ContractService {
newContractMainDO.setStatus(DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode());
} else if (DictEnum.BSE_CTRT_STS_REJECTED.getCode().equals(oldContractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(oldContractMainDO.getStatus())) {
// 其它状态编辑后都为“待审核”
newContractMainDO.setStatus(DictEnum.BSE_CTRT_STS_WAIT_AUDIT.getCode());
}
@@ -1000,6 +999,9 @@ public class ContractServiceImpl implements ContractService {
// 删除品位不计价规则
contractNotMapper.delete(TableFieldConstants.BSE_CTRT_NT_CTRT_ID, id.toString());
// 更新合同状态
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_DELETED.getCode());
contractMainMapper.updateById(contractMainDO);
// 删除合同数据
contractMainMapper.deleteById(id);
@@ -1040,9 +1042,35 @@ public class ContractServiceImpl implements ContractService {
if (StringUtils.isNotBlank(contractMainDO.getProcessInstanceId())) {
// TODO待审核状态重新提交审批处理
// 进入审批流程的合同,查询当前审批的任务节点
// 获取流程当前审批的任务节点
List<BpmTaskRespDTO> taskList = bpmTaskApi.getTaskListByProcessInstanceId(contractMainDO.getProcessInstanceId()).getData();
if (CollectionUtils.isNotEmpty(taskList)) {
BpmTaskRespDTO bpmTaskDto = taskList.get(taskList.size() - 1);
BpmApprovalDetailReqDTO badrDto = new BpmApprovalDetailReqDTO();
badrDto.setProcessInstanceId(contractMainDO.getProcessInstanceId()); // 流程实例id
badrDto.setTaskId(bpmTaskDto.getId()); // 当前审核任务节点id
BpmApprovalDetailRespDTO approvalDetail = bpmProcessInstanceApi.getApprovalDetail(SecurityFrameworkUtils.getLoginUserId(), badrDto).getData();
if (BpmProcessInstanceStatusEnum.REJECT.getStatus().equals(approvalDetail.getStatus())) {
// 如果状态是驳回状态,需要重新创建一个流程实例
BpmProcessInstanceCreateReqDTO pidtoNew = new BpmProcessInstanceCreateReqDTO();
pidtoNew.setProcessDefinitionKey(ProcessConstants.CONTRACT_APPROVAL_PROCESS);
pidtoNew.setBusinessKey(String.valueOf(id));
String data = bpmProcessInstanceApi.createProcessInstance(adminUserRespDTO.getId(), pidtoNew).getData();
if (StringUtils.isNotBlank(data)) {
// 获取流程当前审批的任务节点
List<BpmTaskRespDTO> taskListNew = bpmTaskApi.getTaskListByProcessInstanceId(data).getData();
contractMainDO.setProcessInstanceId(data);
if (CollectionUtils.isNotEmpty(taskListNew)) {
BpmTaskRespDTO undoTask = taskListNew.get(taskListNew.size() - 1);
contractMainDO.setTaskNodeId(undoTask.getId());
}
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode());
contractMainMapper.updateById(contractMainDO);
return true;
}
}
}
} else {
// 未进入审批流程的合同,创建审批流程
@@ -1069,7 +1097,7 @@ public class ContractServiceImpl implements ContractService {
}
@Override
public String approval(ApprovalReqVO reqVO) {
public Boolean approval(ApprovalReqVO reqVO) {
// 合同主键ID
Long id = reqVO.getId();
@@ -1086,18 +1114,59 @@ public class ContractServiceImpl implements ContractService {
}
// 合同状态校验
if (DictEnum.BSE_CTRT_STS_DRAFT.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_REJECTED.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_ARCHIVED.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_DELETED.getCode().equals(contractMainDO.getStatus())) {
if (!DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode().equals(contractMainDO.getStatus())) {
throw exception(CONTRACT_STATUS_NOT_APPROVAL,
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
}
return "";
// 获取当前流程正在审批的任务节点
List<BpmTaskRespDTO> taskList = bpmTaskApi.getTaskListByProcessInstanceId(contractMainDO.getProcessInstanceId()).getData();
BpmTaskRespDTO undoTask = taskList.get(taskList.size() - 1);
// 判断是否流程已经通过、驳回
BpmApprovalDetailReqDTO badrDto = new BpmApprovalDetailReqDTO();
badrDto.setProcessInstanceId(contractMainDO.getProcessInstanceId()); // 流程实例id
badrDto.setTaskId(undoTask.getId()); // 当前审核任务节点id
BpmApprovalDetailRespDTO approvalDetail = bpmProcessInstanceApi.getApprovalDetail(SecurityFrameworkUtils.getLoginUserId(), badrDto).getData();
// 更新合同状态,状态需要根据流程的状态进行判断
contractMainDO.setReviewOpinion(reqVO.getReviewOpinion());
if (approvalDetail.getStatus().equals(BpmProcessInstanceStatusEnum.NOT_START.getStatus())) {
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode());
} else if (approvalDetail.getStatus().equals(BpmProcessInstanceStatusEnum.RUNNING.getStatus())) {
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode());
} else if (approvalDetail.getStatus().equals(BpmProcessInstanceStatusEnum.APPROVE.getStatus())) {
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode());
} else if (approvalDetail.getStatus().equals(BpmProcessInstanceStatusEnum.REJECT.getStatus())) {
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_REJECTED.getCode());
} else if (approvalDetail.getStatus().equals(BpmProcessInstanceStatusEnum.CANCEL.getStatus())) {
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_REJECTED.getCode());
}
if (ObjectUtils.isNotEmpty(undoTask)) {
contractMainDO.setTaskNodeId(undoTask.getId());
}
contractMainMapper.updateById(contractMainDO);
// 需要调用bpm 审核接口更新审批中的状态
if (DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode().equals(reqVO.getStatus()) && ObjectUtils.isNotEmpty(undoTask)) {
if (approvalDetail.getStatus().equals(BpmProcessInstanceStatusEnum.RUNNING.getStatus())) {
BpmTaskApproveReqDTO btarDto = new BpmTaskApproveReqDTO();
btarDto.setId(undoTask.getId());
btarDto.setReason(reqVO.getReviewOpinion());
bpmProcessInstanceApi.approveTask(btarDto);
}
} else if (DictEnum.BSE_CTRT_STS_REJECTED.getCode().equals(reqVO.getStatus()) && ObjectUtils.isNotEmpty(undoTask)) {
if (approvalDetail.getStatus().equals(BpmProcessInstanceStatusEnum.RUNNING.getStatus())) {
BpmTaskRejectReqDTO btrrDto = new BpmTaskRejectReqDTO();
btrrDto.setId(undoTask.getId());
btrrDto.setReason(reqVO.getReviewOpinion());
bpmProcessInstanceApi.rejectTask(btrrDto);
}
}
return true;
}
@Override
@@ -1218,10 +1287,7 @@ public class ContractServiceImpl implements ContractService {
}
@Override
public List<String> submitErp(List<Long> ids) {
// 返回结果
List<String> result = new ArrayList<>();
public Boolean submitErp(List<Long> ids) {
// 遍历合同ID集合
ids.forEach(id -> {
@@ -1231,165 +1297,39 @@ public class ContractServiceImpl implements ContractService {
if (contractMainDO != null) {
// 生成ERP合同映射表
ErpContractSaveReqVO erpContractVO = new ErpContractSaveReqVO();
// 合同主信息表主键:BSE_CTRT_MAIN
erpContractVO.setContractMainId(id);
// 操作标识:OPTN_ID
// 1、先调用009ERP接口查询合同信息
ErpContractPageReqVO pageReqVO = new ErpContractPageReqVO();
// BUKRS 合同签订主体公司代码 收支方向判断如果为“支出”传“ERP甲方公司编码”反之传“ERP乙方公司编码”
// PARTNER 对方客商编号 收支方向判断如果为“支出”传“ERP乙方公司编码”反之传“ERP甲方公司编码”
// INEDR 1-借(销售合同)2-贷(采购合同) 收支方向判断如果为“支出”传“2”反之传“1”
if (DictEnum.ERP_RCV_DLVY_EXPENSES.getCode().equals(contractMainDO.getDirection())) {
pageReqVO.setContractSignNumber(contractMainDO.getSalesCompanyNumber());
pageReqVO.setSupplierNumber(contractMainDO.getSalesCompanyNumber());
pageReqVO.setContractCategory("2");
} else if (DictEnum.ERP_RCV_DLVY_INCOME.getCode().equals(contractMainDO.getDirection())) {
pageReqVO.setContractSignNumber(contractMainDO.getSalesCompanyNumber());
pageReqVO.setSupplierNumber(contractMainDO.getSalesCompanyNumber());
pageReqVO.setContractCategory("1");
}
// ZHTBH 合同编号 合同编号:CTRT_PPR_NUM
pageReqVO.setContractTypeNumber(contractMainDO.getContractPaperNumber());
// ZHTMC 合同名称 合同名称:CTRT_NAME
pageReqVO.setContractName(contractMainDO.getContractName());
PageResult<ErpContractDO> erpContractPage = erpContractService.getErpContractPage(pageReqVO);
if (erpContractPage.getTotal() > 0) {
// 2、如果009接口返回值中“合同编号”字段存在值并且与传入的相同则OPTN_ID值为“1”
erpContractVO.setOperationId("1");
} else {
// 3、如果009接口返回值中“合同编号”字段不存在值根据合同主键查询映射表中是否存在没有删除的数据如果有值为“1”如果没有值为“0”
ErpContractDO erpContract = erpContractService.getErpContractByMainId(id);
if (erpContract != null) {
erpContractVO.setOperationId("1");
} else {
erpContractVO.setOperationId("0");
}
}
// 合同编号:CTRT_PPR_NUM
erpContractVO.setContractPaperNumber(contractMainDO.getContractPaperNumber());
// 合同名称:CTRT_NAME
erpContractVO.setContractName(contractMainDO.getContractName());
// 合同类型编号:CTRT_TP_NUM
erpContractVO.setContractTypeNumber(contractMainDO.getConstructionTypeNumber());
// 合同类型名称:CTRT_TP_NAME
erpContractVO.setContractTypeName(contractMainDO.getConstructionTypeName());
// 合同类别:CTRT_CTGR
erpContractVO.setContractCategory(contractMainDO.getCategory());
// 是否虚拟合同:IS_VRTL_CTRT
erpContractVO.setIsVirtualContract(contractMainDO.getContractVirtual());
// 客商编号:SPLR_NUM 根据合同主表的收支方向判断如果为“支出”值为“ERP乙方公司编码”反之为“ERP甲方公司编码”
// 客商名称:SPLR_NAME 根据合同主表的收支方向判断如果为“支出”值为“ERP乙方公司名称”反之为“ERP甲方公司名称”
if (DictEnum.ERP_RCV_DLVY_EXPENSES.getCode().equals(contractMainDO.getDirection())) {
erpContractVO.setSupplierNumber(contractMainDO.getErpSalesCompanyNumber());
erpContractVO.setSupplierName(contractMainDO.getErpSalesCompanyName());
} else if (DictEnum.ERP_RCV_DLVY_INCOME.getCode().equals(contractMainDO.getDirection())) {
erpContractVO.setSupplierNumber(contractMainDO.getErpPurchaseCompanyNumber());
erpContractVO.setSupplierName(contractMainDO.getErpPurchaseCompanyName());
}
// 代理方:AGT
erpContractVO.setAgent(contractMainDO.getAgent());
// 合同实施主体编号:CTRT_IMPL_NUM 根据合同主表的收支方向判断如果为“支出”值为“ERP甲方公司编码”反之为“ERP乙方公司编码”
// 合同签订主体编号:CTRT_SGN_NUM 根据合同主表的收支方向判断如果为“支出”值为“ERP甲方公司名称”反之为“ERP乙方公司名称”
if (DictEnum.ERP_RCV_DLVY_EXPENSES.getCode().equals(contractMainDO.getDirection())) {
erpContractVO.setContractImplementNumber(contractMainDO.getErpPurchaseCompanyNumber());
erpContractVO.setContractSignNumber(contractMainDO.getErpPurchaseCompanyName());
} else if (DictEnum.ERP_RCV_DLVY_INCOME.getCode().equals(contractMainDO.getDirection())) {
erpContractVO.setContractImplementNumber(contractMainDO.getErpSalesCompanyNumber());
erpContractVO.setContractSignNumber(contractMainDO.getErpSalesCompanyName());
}
// 合同签订日期:SGN_DT
if (contractMainDO.getSignDate() != null) {
erpContractVO.setSignDate(contractMainDO.getSignDate().toLocalDate());
}
// 合同起始日期:STRT_DT
if (contractMainDO.getStartDate() != null) {
erpContractVO.setStartDate(contractMainDO.getStartDate().toLocalDate());
}
// 合同终止日期:STOP_DT
if (contractMainDO.getEndDate() != null) {
erpContractVO.setStopDate(contractMainDO.getEndDate().toLocalDate());
}
// 币种编号:CUR
erpContractVO.setCurrency(contractMainDO.getCurrency());
// 合同总金额(原币-含税):SRC_AMT
erpContractVO.setSourceAmount(contractMainDO.getCooAmount());
// 合同总金额(本位币-含税):BSC_AMT
erpContractVO.setBasicAmount(contractMainDO.getBasicAmount());
// 变更后合同总金额(原币-含税):CHG_SRC_AMT
erpContractVO.setChangeSourceAmount(contractMainDO.getChangeCooAmount());
// 变更后合同总金额(本位币-含税):CHG_BSC_AMT
erpContractVO.setChangeBasicAmount(contractMainDO.getChangeBasicAmount());
// 合同状态编号:STS_NUM 参照060接口
erpContractVO.setStatusNumber(DictEnum.SUBMIT_ERP_CTRT_STS_EF.getCode());
// 合同状态名称:STS_NAME 参照060接口
erpContractVO.setStatusName(DictEnum.SUBMIT_ERP_CTRT_STS_EF.getLabel());
// 是否有预付款:IS_PPYM
erpContractVO.setIsPrepayment(contractMainDO.getHasPrepayment());
// 预付款比例:PPYM_RTIO
erpContractVO.setPrepaymentRatio(contractMainDO.getPrepaymentRatio());
// 预付款金额:PPYM_AMT
erpContractVO.setPrepaymentAmount(contractMainDO.getPrepaymentAmount());
// 履约保证金-变更前(原币):SRC_BFR_BND
erpContractVO.setSourceBeforeBond(contractMainDO.getChangeCooAmountDeposit());
// 履约保证金-变更前(本位币):BSC_BFR_BND
erpContractVO.setBasicBeforeBond(contractMainDO.getChangeBasicAmountDeposit());
// 履约保证金-变更后(原币):SRC_AFT_BND
erpContractVO.setSourceAfterBond(contractMainDO.getChangeCooAmountDeposit());
// 履约保证金-变更后(本位币):BSC_AFT_BND
erpContractVO.setBasicAfterBond(contractMainDO.getChangeBasicAmountDeposit());
// 是否含质保金:IS_QUA_AMT
erpContractVO.setIsQualityassuranceAmount(contractMainDO.getHasQualityAmount());
// 质保金比例:QUA_RTIO
erpContractVO.setQualityassuranceRatio(contractMainDO.getQualityRatio());
// 质保金金额:QUA_AMT
erpContractVO.setQualityassuranceAmount(contractMainDO.getQualityAmount());
// 是否内部企业:IS_INTL
erpContractVO.setIsInternal(contractMainDO.getIsInternal());
// 收支性质:NTR
erpContractVO.setNature(contractMainDO.getDirection());
// 备注信息:RMK
erpContractVO.setRemark(contractMainDO.getRemark());
// 是否框架合同:IS_FMWK
erpContractVO.setIsFramework(contractMainDO.getIsFramework());
// 境内/境外:IS_DOM
erpContractVO.setIsDomestic(contractMainDO.getIsDomestic());
// 达到收款条件金额:PYEE_CND_AMT
erpContractVO.setPayeeConditionAmount(contractMainDO.getPayeeConditionAmount());
// 建筑服务发生地:ARCH_SVC_PLCE
erpContractVO.setArchitectureServicePlace(contractMainDO.getArchitectureServicePlace());
// 合同状态校验
if (!(DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_VOID.getCode().equals(contractMainDO.getStatus())
|| DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus()))) {
// 公司编号
erpContractVO.setCompanyId(contractMainDO.getCompanyId());
// 公司名称
erpContractVO.setCompanyName(contractMainDO.getCompanyName());
// 部门编号
erpContractVO.setDeptId(contractMainDO.getDeptId());
// 部门名称
erpContractVO.setDeptName(contractMainDO.getDeptName());
// 岗位编号
erpContractVO.setPostId(contractMainDO.getPostId());
// 创建者
erpContractVO.setCreatorName(contractMainDO.getCreatorName());
// 更新者
erpContractVO.setUpdaterName(contractMainDO.getUpdaterName());
throw exception(CONTRACT_STATUS_NOT_SUBMIT_ERP,
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
}
// 生成ERP合同映射表
ErpContractSaveReqVO erpContractVO = getErpContract(contractMainDO);
// 调用ERP模块
String erpResult = null;
try {
erpResult = erpContractService.submitErp(erpContractVO);
} catch (Exception e) {
erpResult = e.getMessage();
}
Map<Boolean, String> erpResult = sendToErp(erpContractVO);
log.info("合同提交ERP结果{}", erpResult);
result.add(id.toString() + ":" + erpResult);
} else {
result.add(id.toString() + ":" + CONTRACT_NOT_EXISTS);
throw exception(CONTRACT_NOT_EXISTS);
}
});
return result;
return true;
}
private Map<Boolean, String> sendToErp(ErpContractSaveReqVO erpContractVO) {
Map<Boolean, String> erpResult = new HashMap<>();
try {
String result = erpContractService.submitErp(erpContractVO);
erpResult.put(true, result);
} catch (Exception e) {
erpResult.put(false, e.getMessage());
}
return erpResult;
}
@Override
@@ -1535,6 +1475,9 @@ public class ContractServiceImpl implements ContractService {
contractMainMapper.updateById(contractMainDO);
});
// 重新提交erp
submitErp(ids);
return true;
}
@@ -1563,9 +1506,160 @@ public class ContractServiceImpl implements ContractService {
contractMainMapper.updateById(contractMainDO);
});
// 重新提交erp
submitErp(ids);
return true;
}
private ErpContractSaveReqVO getErpContract(ContractMainDO contractMainDO) {
ErpContractSaveReqVO erpContractVO = new ErpContractSaveReqVO();
// 合同主信息表主键:BSE_CTRT_MAIN
erpContractVO.setContractMainId(contractMainDO.getId());
// 操作标识:OPTN_ID
// 1、先调用009ERP接口查询合同信息
ErpContractPageReqVO pageReqVO = new ErpContractPageReqVO();
// BUKRS 合同签订主体公司代码 收支方向判断如果为“支出”传“ERP甲方公司编码”反之传“ERP乙方公司编码”
// PARTNER 对方客商编号 收支方向判断如果为“支出”传“ERP乙方公司编码”反之传“ERP甲方公司编码”
// INEDR 1-借(销售合同)2-贷(采购合同) 收支方向判断如果为“支出”传“2”反之传“1”
if (DictEnum.ERP_RCV_DLVY_EXPENSES.getCode().equals(contractMainDO.getDirection())) {
pageReqVO.setContractSignNumber(contractMainDO.getSalesCompanyNumber());
pageReqVO.setSupplierNumber(contractMainDO.getSalesCompanyNumber());
pageReqVO.setContractCategory("2");
} else if (DictEnum.ERP_RCV_DLVY_INCOME.getCode().equals(contractMainDO.getDirection())) {
pageReqVO.setContractSignNumber(contractMainDO.getSalesCompanyNumber());
pageReqVO.setSupplierNumber(contractMainDO.getSalesCompanyNumber());
pageReqVO.setContractCategory("1");
}
// ZHTBH 合同编号 合同编号:CTRT_PPR_NUM
pageReqVO.setContractTypeNumber(contractMainDO.getContractPaperNumber());
// ZHTMC 合同名称 合同名称:CTRT_NAME
pageReqVO.setContractName(contractMainDO.getContractName());
PageResult<ErpContractDO> erpContractPage = erpContractService.getErpContractPage(pageReqVO);
if (erpContractPage.getTotal() > 0) {
// 2、如果009接口返回值中“合同编号”字段存在值并且与传入的相同则OPTN_ID值为“1”
erpContractVO.setOperationId("1");
} else {
// 3、如果009接口返回值中“合同编号”字段不存在值根据合同主键查询映射表中是否存在没有删除的数据如果有值为“1”如果没有值为“0”
ErpContractDO erpContract = erpContractService.getErpContractByMainId(contractMainDO.getId());
if (erpContract != null) {
erpContractVO.setOperationId("1");
} else {
erpContractVO.setOperationId("0");
}
}
// 合同编号:CTRT_PPR_NUM
erpContractVO.setContractPaperNumber(contractMainDO.getContractPaperNumber());
// 合同名称:CTRT_NAME
erpContractVO.setContractName(contractMainDO.getContractName());
// 合同类型编号:CTRT_TP_NUM
erpContractVO.setContractTypeNumber(contractMainDO.getConstructionTypeNumber());
// 合同类型名称:CTRT_TP_NAME
erpContractVO.setContractTypeName(contractMainDO.getConstructionTypeName());
// 合同类别:CTRT_CTGR
erpContractVO.setContractCategory(contractMainDO.getCategory());
// 是否虚拟合同:IS_VRTL_CTRT
erpContractVO.setIsVirtualContract(contractMainDO.getContractVirtual());
// 客商编号:SPLR_NUM 根据合同主表的收支方向判断如果为“支出”值为“ERP乙方公司编码”反之为“ERP甲方公司编码”
// 客商名称:SPLR_NAME 根据合同主表的收支方向判断如果为“支出”值为“ERP乙方公司名称”反之为“ERP甲方公司名称”
if (DictEnum.ERP_RCV_DLVY_EXPENSES.getCode().equals(contractMainDO.getDirection())) {
erpContractVO.setSupplierNumber(contractMainDO.getErpSalesCompanyNumber());
erpContractVO.setSupplierName(contractMainDO.getErpSalesCompanyName());
} else if (DictEnum.ERP_RCV_DLVY_INCOME.getCode().equals(contractMainDO.getDirection())) {
erpContractVO.setSupplierNumber(contractMainDO.getErpPurchaseCompanyNumber());
erpContractVO.setSupplierName(contractMainDO.getErpPurchaseCompanyName());
}
// 代理方:AGT
erpContractVO.setAgent(contractMainDO.getAgent());
// 合同实施主体编号:CTRT_IMPL_NUM 根据合同主表的收支方向判断如果为“支出”值为“ERP甲方公司编码”反之为“ERP乙方公司编码”
// 合同签订主体编号:CTRT_SGN_NUM 根据合同主表的收支方向判断如果为“支出”值为“ERP甲方公司名称”反之为“ERP乙方公司名称”
if (DictEnum.ERP_RCV_DLVY_EXPENSES.getCode().equals(contractMainDO.getDirection())) {
erpContractVO.setContractImplementNumber(contractMainDO.getErpPurchaseCompanyNumber());
erpContractVO.setContractSignNumber(contractMainDO.getErpPurchaseCompanyName());
} else if (DictEnum.ERP_RCV_DLVY_INCOME.getCode().equals(contractMainDO.getDirection())) {
erpContractVO.setContractImplementNumber(contractMainDO.getErpSalesCompanyNumber());
erpContractVO.setContractSignNumber(contractMainDO.getErpSalesCompanyName());
}
// 合同签订日期:SGN_DT
if (contractMainDO.getSignDate() != null) {
erpContractVO.setSignDate(contractMainDO.getSignDate().toLocalDate());
}
// 合同起始日期:STRT_DT
if (contractMainDO.getStartDate() != null) {
erpContractVO.setStartDate(contractMainDO.getStartDate().toLocalDate());
}
// 合同终止日期:STOP_DT
if (contractMainDO.getEndDate() != null) {
erpContractVO.setStopDate(contractMainDO.getEndDate().toLocalDate());
}
// 币种编号:CUR
erpContractVO.setCurrency(contractMainDO.getCurrency());
// 合同总金额(原币-含税):SRC_AMT
erpContractVO.setSourceAmount(contractMainDO.getCooAmount());
// 合同总金额(本位币-含税):BSC_AMT
erpContractVO.setBasicAmount(contractMainDO.getBasicAmount());
// 变更后合同总金额(原币-含税):CHG_SRC_AMT
erpContractVO.setChangeSourceAmount(contractMainDO.getChangeCooAmount());
// 变更后合同总金额(本位币-含税):CHG_BSC_AMT
erpContractVO.setChangeBasicAmount(contractMainDO.getChangeBasicAmount());
// 合同状态编号:STS_NUM 参照060接口
erpContractVO.setStatusNumber(DictEnum.SUBMIT_ERP_CTRT_STS_EF.getCode());
// 合同状态名称:STS_NAME 参照060接口
erpContractVO.setStatusName(DictEnum.SUBMIT_ERP_CTRT_STS_EF.getLabel());
// 是否有预付款:IS_PPYM
erpContractVO.setIsPrepayment(contractMainDO.getHasPrepayment());
// 预付款比例:PPYM_RTIO
erpContractVO.setPrepaymentRatio(contractMainDO.getPrepaymentRatio());
// 预付款金额:PPYM_AMT
erpContractVO.setPrepaymentAmount(contractMainDO.getPrepaymentAmount());
// 履约保证金-变更前(原币):SRC_BFR_BND
erpContractVO.setSourceBeforeBond(contractMainDO.getChangeCooAmountDeposit());
// 履约保证金-变更前(本位币):BSC_BFR_BND
erpContractVO.setBasicBeforeBond(contractMainDO.getChangeBasicAmountDeposit());
// 履约保证金-变更后(原币):SRC_AFT_BND
erpContractVO.setSourceAfterBond(contractMainDO.getChangeCooAmountDeposit());
// 履约保证金-变更后(本位币):BSC_AFT_BND
erpContractVO.setBasicAfterBond(contractMainDO.getChangeBasicAmountDeposit());
// 是否含质保金:IS_QUA_AMT
erpContractVO.setIsQualityassuranceAmount(contractMainDO.getHasQualityAmount());
// 质保金比例:QUA_RTIO
erpContractVO.setQualityassuranceRatio(contractMainDO.getQualityRatio());
// 质保金金额:QUA_AMT
erpContractVO.setQualityassuranceAmount(contractMainDO.getQualityAmount());
// 是否内部企业:IS_INTL
erpContractVO.setIsInternal(contractMainDO.getIsInternal());
// 收支性质:NTR
erpContractVO.setNature(contractMainDO.getDirection());
// 备注信息:RMK
erpContractVO.setRemark(contractMainDO.getRemark());
// 是否框架合同:IS_FMWK
erpContractVO.setIsFramework(contractMainDO.getIsFramework());
// 境内/境外:IS_DOM
erpContractVO.setIsDomestic(contractMainDO.getIsDomestic());
// 达到收款条件金额:PYEE_CND_AMT
erpContractVO.setPayeeConditionAmount(contractMainDO.getPayeeConditionAmount());
// 建筑服务发生地:ARCH_SVC_PLCE
erpContractVO.setArchitectureServicePlace(contractMainDO.getArchitectureServicePlace());
// 公司编号
erpContractVO.setCompanyId(contractMainDO.getCompanyId());
// 公司名称
erpContractVO.setCompanyName(contractMainDO.getCompanyName());
// 部门编号
erpContractVO.setDeptId(contractMainDO.getDeptId());
// 部门名称
erpContractVO.setDeptName(contractMainDO.getDeptName());
// 岗位编号
erpContractVO.setPostId(contractMainDO.getPostId());
// 创建者
erpContractVO.setCreatorName(contractMainDO.getCreatorName());
// 更新者
erpContractVO.setUpdaterName(contractMainDO.getUpdaterName());
return erpContractVO;
}
/**
* 校验合同内容
*

View File

@@ -110,45 +110,39 @@ public class ErpAssetServiceImpl implements ErpAssetService {
@Transactional
@XxlJob("getErpAssetTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.资产卡片;
String funcnr = funcnrEnum.getFuncnr();
String key = "erpMap" + funcnr;
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
initializeMap(key);
}
// 构建req参数
Map<String, Object> req = new HashMap<>();
JSONArray dataArrayALL = new JSONArray();
String companyKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companyKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.资产卡片;
String funcnr = funcnrEnum.getFuncnr();
String key = "erpMap" + funcnr;
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
initializeMap(key);
}
// 构建req参数
Map<String, Object> req = new HashMap<>();
JSONArray dataArrayALL = new JSONArray();
String companyKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(companyKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -202,7 +196,7 @@ public class ErpAssetServiceImpl implements ErpAssetService {
Map<String, Long> deleteNumbers = new HashMap<>();
for (String number : numbers.keySet()) {
if (!dataArrayNumbers.contains(number)) {
deleteNumbers.put(number,numbers.get(number));
deleteNumbers.put(number, numbers.get(number));
}
}
return new ProcessingResult(toUpdate, toInsert, deleteNumbers, key);
@@ -222,8 +216,8 @@ public class ErpAssetServiceImpl implements ErpAssetService {
.in(ErpAssetDO::getMainAssetNumber, result.toInsert.stream().map(ErpAssetDO::getMainAssetNumber).collect(Collectors.toList()))
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(asset -> asset.getCompanyNumber() + "-" + asset.getMainAssetNumber(), ErpAssetDO::getId));
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
.collect(Collectors.toMap(asset -> asset.getCompanyNumber() + "-" + asset.getMainAssetNumber(), ErpAssetDO::getId,(existing, replacement) -> replacement));
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
if (!result.toUpdate.isEmpty()) {
erpAssetMapper.updateBatch(result.toUpdate);
@@ -242,10 +236,10 @@ public class ErpAssetServiceImpl implements ErpAssetService {
private static class ProcessingResult {
private final List<ErpAssetDO> toUpdate;
private final List<ErpAssetDO> toInsert;
private final Map<String,Long> deleteNumbers;
private final Map<String, Long> deleteNumbers;
private final String key;
public ProcessingResult(List<ErpAssetDO> toUpdate, List<ErpAssetDO> toInsert, Map<String,Long> deleteNumbers, String key) {
public ProcessingResult(List<ErpAssetDO> toUpdate, List<ErpAssetDO> toInsert, Map<String, Long> deleteNumbers, String key) {
this.toUpdate = toUpdate;
this.toInsert = toInsert;
this.deleteNumbers = deleteNumbers;

View File

@@ -117,44 +117,38 @@ public class ErpBomServiceImpl implements ErpBomService {
@Transactional
@XxlJob("getErpBomTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.BOM清单;
String funcnr = funcnrEnum.getFuncnr();
String key = "erpMap" + funcnr;
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_REDIS_NOT_EXISTS);
}
for (String factoryNumber : redisCache.keySet()) {
req.put("WERKS", factoryNumber);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.BOM清单;
String funcnr = funcnrEnum.getFuncnr();
String key = "erpMap" + funcnr;
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_REDIS_NOT_EXISTS);
}
for (String factoryNumber : redisCache.keySet()) {
req.put("WERKS", factoryNumber);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -168,7 +162,7 @@ public class ErpBomServiceImpl implements ErpBomService {
List<ErpBomDetailDO> erpBomDetailDOList = new ArrayList<>();
Map<String, Long> addnumbers = new HashMap<>();
List<String> dataArrayNumbers = new ArrayList<>();
for (int i = 0; i < dataArray.size(); i++) {
JSONObject dataJson = dataArray.getJSONObject(i);
if (dataJson != null) {
@@ -179,10 +173,10 @@ public class ErpBomServiceImpl implements ErpBomService {
bomDO.setMaterialDescription(dataJson.getString("MAKTX"));
bomDO.setQuantity(dataJson.getBigDecimal("BMENG"));
bomDO.setUnit(dataJson.getString("BMEIN"));
String number = bomDO.getFactoryNumber() + "-" + bomDO.getUpMaterial() + "-" + bomDO.getUseItem();
dataArrayNumbers.add(number);
if (numbers.containsKey(number)) {
// 更新
bomDO.setId(numbers.get(number));
@@ -231,17 +225,17 @@ public class ErpBomServiceImpl implements ErpBomService {
if (!result.toUpdate.isEmpty()) {
erpBomMapper.updateBatch(result.toUpdate);
}
// 保存或更新BOM详情
if (!result.erpBomDetailDOList.isEmpty()) {
bomDetailService.saveOrUpdateErpBomDetail(result.erpBomDetailDOList);
}
// 更新Redis缓存
if (!result.addnumbers.isEmpty()) {
myRedisConfig.addRedisCacheMap(result.key, result.addnumbers);
}
if (!result.deleteNumbers.isEmpty()) {
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
}
@@ -257,8 +251,8 @@ public class ErpBomServiceImpl implements ErpBomService {
private final List<String> deleteNumbers;
private final List<ErpBomDetailDO> erpBomDetailDOList;
public ProcessingResult(List<ErpBomDO> toUpdate, String key, Map<String, Long> addnumbers,
List<String> deleteNumbers, List<ErpBomDetailDO> erpBomDetailDOList) {
public ProcessingResult(List<ErpBomDO> toUpdate, String key, Map<String, Long> addnumbers,
List<String> deleteNumbers, List<ErpBomDetailDO> erpBomDetailDOList) {
this.toUpdate = toUpdate;
this.key = key;
this.addnumbers = addnumbers;

View File

@@ -121,32 +121,25 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
@Transactional
@XxlJob("getCompanyTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.公司代码;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
initializeMap(key);
}
// 1. 调用ERP接口获取数据
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. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArray, funcnrEnum);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
// log.error("调用ERP RFC接口失败: {}", e);
throw e;
// throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.公司代码;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
initializeMap(key);
}
// 1. 调用ERP接口获取数据
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. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArray, funcnrEnum);
// 3. 批量保存数据
saveData(result);
}
@Override
@@ -284,10 +277,10 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody.toJSONString(), headers);
// 发送POST请求
RestTemplate restTemplate = new RestTemplate();
try{
try {
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
return url + requestEntity + response;
}catch (Exception e){
} catch (Exception e) {
return url + requestEntity;
}
}

View File

@@ -183,53 +183,47 @@ public class ErpContractServiceImpl implements ErpContractService {
@Transactional
@XxlJob("getErpContractTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.合同信息;
String funcnr = funcnrEnum.getFuncnr();
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.合同信息;
String funcnr = funcnrEnum.getFuncnr();
Map<String, Object> req = new HashMap<>();
JSONArray dataArrayALL = new JSONArray();
String commanyKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(commanyKey);
if (CollUtil.isEmpty(redisCache)) {
return;
}
String cstmKey = "erpMap" + OftenEnum.FuncnrEnum.客商信息.getFuncnr();
Map<String, Long> redisCachecstmKey = myRedisConfig.getRedisCacheMap(cstmKey);
if (CollUtil.isEmpty(redisCachecstmKey)) {
return;
}
// 1. 调用ERP接口获取数据
for (String INEDR : new String[]{"1", "2"}) {
req.put("INEDR", INEDR);
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
for (String partner : redisCachecstmKey.keySet()) {
req.put("PARTNER", partner);
Map<String, Object> req = new HashMap<>();
JSONArray dataArrayALL = new JSONArray();
String commanyKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(commanyKey);
if (CollUtil.isEmpty(redisCache)) {
return;
}
String cstmKey = "erpMap" + OftenEnum.FuncnrEnum.客商信息.getFuncnr();
Map<String, Long> redisCachecstmKey = myRedisConfig.getRedisCacheMap(cstmKey);
if (CollUtil.isEmpty(redisCachecstmKey)) {
return;
}
// 1. 调用ERP接口获取数据
for (String INEDR : new String[]{"1", "2"}) {
req.put("INEDR", INEDR);
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
for (String partner : redisCachecstmKey.keySet()) {
req.put("PARTNER", partner);
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray!= null) {
dataArrayALL.addAll(dataArray);
}
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray != null) {
dataArrayALL.addAll(dataArray);
}
}
}
if (CollUtil.isEmpty(dataArrayALL)) {
throw exception(ERP_CONTRACT_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
}
if (CollUtil.isEmpty(dataArrayALL)) {
throw exception(ERP_CONTRACT_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
// 3. 批量保存数据
saveData(result);
}
@Override
@@ -338,7 +332,7 @@ public class ErpContractServiceImpl implements ErpContractService {
head.put("DDSKJE", erpContract.getPayeeConditionAmount());
Map<String, Object> req = new HashMap<>();
req.put("head", head);
req.put("header", head);
erpSubmitReqDTO.setReq(req);
HashMap<String, String> response = erpExternalApi.submitDataToErp(erpSubmitReqDTO);

View File

@@ -76,12 +76,12 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
}
@Override
public void deleteErpCostcenterListByIds(List<Long> ids) {
public void deleteErpCostcenterListByIds(List<Long> ids) {
// 校验存在
validateErpCostcenterExists(ids);
// 删除
erpCostcenterMapper.deleteByIds(ids);
}
}
private void validateErpCostcenterExists(List<Long> ids) {
List<ErpCostcenterDO> list = erpCostcenterMapper.selectByIds(ids);
@@ -110,46 +110,40 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
@Transactional
@XxlJob("getErpCostcenterTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.成本中心;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnr;
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 = myRedisConfig.getRedisCacheMap(commanyKey);
if (CollUtil.isEmpty(redisCache)) {
return;
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.成本中心;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnr;
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 = myRedisConfig.getRedisCacheMap(commanyKey);
if (CollUtil.isEmpty(redisCache)) {
return;
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -178,7 +172,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
DO.setEndDate(LocalDateTime.parse(dataJson.getString("DATBI") + "T00:00:00"));
}
DO.setScopeName(dataJson.getString("FKBTX"));
if (numbers.get(number)!=null) {
if (numbers.get(number) != null) {
// 更新
DO.setId(numbers.get(number));
toUpdate.add(DO);
@@ -196,7 +190,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
deleteNumbers.add(number);
}
}
return new ProcessingResult(toUpdate, toInsert,deleteNumbers,key);
return new ProcessingResult(toUpdate, toInsert, deleteNumbers, key);
}
/**
@@ -216,7 +210,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(ErpCostcenterDO::getNumber, ErpCostcenterDO::getId));
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
if (!result.toUpdate.isEmpty()) {
erpCostcenterMapper.updateBatch(result.toUpdate);
@@ -224,7 +218,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
if (!result.deleteNumbers.isEmpty()) {
// 使用 in 条件批量删除,提高删除效率
erpCostcenterMapper.delete(new LambdaQueryWrapperX<ErpCostcenterDO>().in(ErpCostcenterDO::getNumber, result.deleteNumbers));
myRedisConfig.deleteRedisCacheMap(result.key,result.deleteNumbers);
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
}
}
@@ -237,13 +231,14 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
private final List<String> deleteNumbers;
private final String key;
public ProcessingResult(List<ErpCostcenterDO> toUpdate, List<ErpCostcenterDO> toInsert,List<String> deleteNumbers,String key) {
public ProcessingResult(List<ErpCostcenterDO> toUpdate, List<ErpCostcenterDO> toInsert, List<String> deleteNumbers, String key) {
this.toUpdate = toUpdate;
this.toInsert = toInsert;
this.deleteNumbers = deleteNumbers;
this.key = key;
}
}
private void initializeMap(String key) {
Map<String, Long> existingNumbers = erpCostcenterMapper.selectList(new LambdaQueryWrapperX<ErpCostcenterDO>())
.stream()

View File

@@ -110,50 +110,44 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
@Transactional
@XxlJob("getErpCustomerTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.客商信息;
String funcnr = funcnrEnum.getFuncnr();
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.客商信息;
String funcnr = funcnrEnum.getFuncnr();
String key = "erpMap" + funcnrEnum.getFuncnr();
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<>();
// 构建datum参数数组
datumEntry.put("sign", "I");
datumEntry.put("option", "EQ");
datumEntry.put("low", LocalDate.now().toString());
datumList.add(datumEntry);
req.put(funcnrEnum.getDatekey(), datumList);
// 1. 调用ERP接口获取数据
JSONArray dataArrayALL = new JSONArray();
for (OftenEnum.ModeTypeEnum type : OftenEnum.ModeTypeEnum.values()) {
req.put("mode", type.modetype);
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);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
String key = "erpMap" + funcnrEnum.getFuncnr();
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<>();
// 构建datum参数数组
datumEntry.put("sign", "I");
datumEntry.put("option", "EQ");
datumEntry.put("low", LocalDate.now().toString());
datumList.add(datumEntry);
req.put(funcnrEnum.getDatekey(), datumList);
// 1. 调用ERP接口获取数据
JSONArray dataArrayALL = new JSONArray();
for (OftenEnum.ModeTypeEnum type : OftenEnum.ModeTypeEnum.values()) {
req.put("mode", type.modetype);
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);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -169,25 +163,30 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
for (int i = 0; i < dataArray.size(); i++) {
JSONObject dataJson = dataArray.getJSONObject(i);
if (dataJson != null) {
String number = dataJson.getString(funcnrEnum.getDatakey()).trim();
String number = dataJson.getString(funcnrEnum.getDatakey());
if (number != null) {
number = number.trim();
}
ErpCustomerDO DO = new ErpCustomerDO();
DO.setName(dataJson.getString("NAME_ORG1"));
DO.setNumber(number);
DO.setAccountGroup(dataJson.getString("BU_GROUP"));
DO.setDescription(dataJson.getString("BU_SORT1"));
DO.setCenterNumber(dataJson.getString("BU_SORT2"));
if (!dataJson.getString("CRDAT").equals("0000-00-00")) {
DO.setCreateDate(LocalDateTime.parse(dataJson.getString("CRDAT") + "T00:00:00"));
String crdat = dataJson.getString("CRDAT");
if (crdat != null && !crdat.equals("0000-00-00")) {
DO.setCreateDate(LocalDateTime.parse(crdat + "T00:00:00"));
}
if (!dataJson.getString("CHDAT").equals("0000-00-00")) {
DO.setRepairDate(LocalDateTime.parse(dataJson.getString("CHDAT") + "T00:00:00"));
String chdat = dataJson.getString("CHDAT");
if (chdat != null && !chdat.equals("0000-00-00")) {
DO.setRepairDate(LocalDateTime.parse(chdat + "T00:00:00"));
}
DO.setIsGiveback(dataJson.getString("XDELE"));
DO.setIsProvisional(dataJson.getString("XBLCK"));
// DO.setType(type.modetype);
// 使用 Map 优化查找效率,避免每次遍历 comnumbers 列表
if (numbers.get(number)!=null) {
if (number != null && numbers.get(number) != null) {
// 更新
DO.setId(numbers.get(number));
toUpdate.add(DO);
@@ -218,7 +217,7 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(ErpCustomerDO::getNumber, ErpCustomerDO::getId));
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
if (!result.toUpdate.isEmpty()) {
erpCustomerMapper.updateBatch(result.toUpdate);

View File

@@ -55,7 +55,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
// 插入
ErpFactoryDO erpFactory = BeanUtils.toBean(createReqVO, ErpFactoryDO.class);
// 工厂编码自动生成,格式 GC-0001,依次新增
if (erpFactory.getNumber() == null){
if (erpFactory.getNumber() == null) {
String maxCode = erpFactoryMapper.selectMaxCode();
if (maxCode == null) {
erpFactory.setNumber("GC-0001");
@@ -80,7 +80,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
validateErpFactoryExists(updateReqVO.getId());
// 更新
ErpFactoryDO updateObj = BeanUtils.toBean(updateReqVO, ErpFactoryDO.class);
if (updateObj.getType().equals("ERP")||updateObj.getIsEnable().equals("1")){
if (updateObj.getType().equals("ERP") || updateObj.getIsEnable().equals("1")) {
throw exception(ERP_FACTORY_NOT_ALLOW_UPDATE);
}
erpFactoryMapper.updateById(updateObj);
@@ -95,12 +95,12 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
}
@Override
public void deleteErpFactoryListByIds(List<Long> ids) {
public void deleteErpFactoryListByIds(List<Long> ids) {
// 校验存在
validateErpFactoryExists(ids);
// 删除
erpFactoryMapper.deleteByIds(ids);
}
}
private void validateErpFactoryExists(List<Long> ids) {
List<ErpFactoryDO> list = erpFactoryMapper.selectByIds(ids);
@@ -164,53 +164,47 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
@Transactional
@XxlJob("getErpFactoryTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.工厂信息;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
initializeMap(key);
}
// 1. 调用ERP接口获取数据
Map<String, Object> req = new HashMap<>();
JSONArray dataArrayALL = new JSONArray();
String companykey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companykey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
for (String companyNumber : redisCache.keySet()) {
req.put("BUKRS", companyNumber);
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray == null || dataArray.isEmpty()) {
continue;
}
// 往每个子项中添加BUKRS字段
for (int j = 0; j < dataArray.size(); j++) {
JSONObject item = dataArray.getJSONObject(j);
if (item != null) {
item.put("BUKRS", companyNumber);
}
}
dataArrayALL.addAll(dataArray);
}
if (CollUtil.isEmpty(dataArrayALL)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.工厂信息;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
initializeMap(key);
}
// 1. 调用ERP接口获取数据
Map<String, Object> req = new HashMap<>();
JSONArray dataArrayALL = new JSONArray();
String companykey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(companykey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
for (String companyNumber : redisCache.keySet()) {
req.put("BUKRS", companyNumber);
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray == null || dataArray.isEmpty()) {
continue;
}
// 往每个子项中添加BUKRS字段
for (int j = 0; j < dataArray.size(); j++) {
JSONObject item = dataArray.getJSONObject(j);
if (item != null) {
item.put("BUKRS", companyNumber);
}
}
dataArrayALL.addAll(dataArray);
}
if (CollUtil.isEmpty(dataArrayALL)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -232,7 +226,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
DO.setNumber(number);
DO.setErpCompanyNumber(dataJson.getString("BUKRS"));
DO.setType("ERP");
if (numbers.get(number)!=null) {
if (numbers.get(number) != null) {
// 更新
DO.setId(numbers.get(number));
toUpdate.add(DO);
@@ -251,7 +245,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
deleteNumbers.add(number);
}
}
return new ProcessingResult(toUpdate, toInsert,key,deleteNumbers);
return new ProcessingResult(toUpdate, toInsert, key, deleteNumbers);
}
/**
@@ -271,7 +265,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(ErpFactoryDO::getNumber, ErpFactoryDO::getId));
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
if (!result.toUpdate.isEmpty()) {
erpFactoryMapper.updateBatch(result.toUpdate);
@@ -292,7 +286,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
private final String key;
private final List<String> deleteNumbers;
public ProcessingResult(List<ErpFactoryDO> toUpdate, List<ErpFactoryDO> toInsert,String key,List<String> deleteNumbers) {
public ProcessingResult(List<ErpFactoryDO> toUpdate, List<ErpFactoryDO> toInsert, String key, List<String> deleteNumbers) {
this.toUpdate = toUpdate;
this.toInsert = toInsert;
this.key = key;

View File

@@ -108,47 +108,41 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
@Transactional
@XxlJob("getErpInternalOrderTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.内部订单;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
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 = myRedisConfig.getRedisCacheMap(companyCode);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.内部订单;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
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 = myRedisConfig.getRedisCacheMap(companyCode);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -171,7 +165,7 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
DO.setType(dataJson.getString("AUART"));
DO.setIsOff(dataJson.getString("PHAS3"));
DO.setIsFinish(dataJson.getString("PHAS2"));
if (numbers.get(number)!=null) {
if (numbers.get(number) != null) {
// 更新
DO.setId(numbers.get(number));
toUpdate.add(DO);
@@ -210,7 +204,7 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(ErpInternalOrderDO::getNumber, ErpInternalOrderDO::getId));
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
if (!result.toUpdate.isEmpty()) {
erpInternalOrderMapper.updateBatch(result.toUpdate);

View File

@@ -164,7 +164,7 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
MaterialOtherDTO dto = new MaterialOtherDTO();
dto.setMaterialNumber(respVO.getDownCenterNumber());
List<MaterialOtherDTO> dtos = baseApi.getMaterialOtherNoPage(dto);
if (dtos != null){
if (dtos != null) {
respVO.setMaterialOtherDTOS(dtos);
}
}
@@ -178,43 +178,37 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
@Transactional
@XxlJob("getErpMaterialTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.物料数据;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erp" + funcnrEnum.getFuncnr();
if (myRedisConfig.getRedisCache(key) == null) {
initialize(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", "2021-05-20");
datumEntry.put("low", LocalDate.now().toString());
datumList.add(datumEntry);
req.put(funcnrEnum.getDatekey(), datumList);
// 1. 调用ERP接口获取数据
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. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArray, funcnrEnum);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.物料数据;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erp" + funcnrEnum.getFuncnr();
if (myRedisConfig.getRedisCache(key) == null) {
initialize(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", "2021-05-20");
datumEntry.put("low", LocalDate.now().toString());
datumList.add(datumEntry);
req.put(funcnrEnum.getDatekey(), datumList);
// 1. 调用ERP接口获取数据
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. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArray, funcnrEnum);
// 3. 批量保存数据
saveData(result);
}
/**

View File

@@ -66,12 +66,12 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
}
@Override
public void deleteErpProcessDetailListByIds(List<Long> ids) {
public void deleteErpProcessDetailListByIds(List<Long> ids) {
// 校验存在
validateErpProcessDetailExists(ids);
// 删除
erpProcessDetailMapper.deleteByIds(ids);
}
}
private void validateErpProcessDetailExists(List<Long> ids) {
List<ErpProcessDetailDO> list = erpProcessDetailMapper.selectByIds(ids);
@@ -115,10 +115,10 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
List<String> dataArrayNumbers = new ArrayList<>();
Map<String, Long> existingNumbers = myRedisConfig.getRedisCacheMap(key);
for (ErpProcessDetailDO updateReqVO : updateReqVOS) {
if (updateReqVO.getProcessingName() == null|| updateReqVO.getProcessingName().isEmpty()){
if (updateReqVO.getProcessingName() == null || updateReqVO.getProcessingName().isEmpty()) {
continue;
}
String mapKey = updateReqVO.getProcessId() + "-" + updateReqVO.getProcessingNumber();
String mapKey = updateReqVO.getProcessId() + "-" + updateReqVO.getProcessingNumber()+"-" + updateReqVO.getWorkCenterNumber();
if (existingNumbers.containsKey(mapKey)) {
updateReqVO.setId(existingNumbers.get(mapKey));
}
@@ -149,10 +149,12 @@ 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::getWorkCenterNumber, result.toInsert.stream().map(ErpProcessDetailDO::getWorkCenterNumber).distinct().collect(Collectors.toList()))
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(asset -> asset.getProcessId() + "-" + asset.getProcessingNumber(), ErpProcessDetailDO::getId));
.collect(Collectors.toMap(
asset -> asset.getProcessId() + "-" + asset.getProcessingNumber() + "-" + asset.getWorkCenterNumber(),
ErpProcessDetailDO::getId, (existing, replacement) -> replacement));
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
if (!result.toUpdate.isEmpty()) {
@@ -186,7 +188,7 @@ 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();
String mapKey = asset.getProcessId() + "-" + asset.getProcessingNumber()+ "-" + asset.getWorkCenterNumber();
existingNumbers.put(mapKey, asset.getId());
}
myRedisConfig.addRedisCacheMap(key, existingNumbers);

View File

@@ -114,45 +114,39 @@ public class ErpProcessServiceImpl implements ErpProcessService {
@Transactional
@XxlJob("getErpProcessTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.工艺路线;
String funcnr = funcnrEnum.getFuncnr();
String key = "erpMap" + funcnr;
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String factoryNumber : redisCache.keySet()) {
req.put("WERKS", factoryNumber);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.工艺路线;
String funcnr = funcnrEnum.getFuncnr();
String key = "erpMap" + funcnr;
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String factoryNumber : redisCache.keySet()) {
req.put("WERKS", factoryNumber);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -171,16 +165,25 @@ public class ErpProcessServiceImpl implements ErpProcessService {
JSONObject dataJson = dataArray.getJSONObject(i);
if (dataJson != null) {
ErpProcessDO DO = new ErpProcessDO();
DO.setFactoryNumber(dataJson.getString("WERKS"));
DO.setMaterialNumber(dataJson.getString("MATNR"));
DO.setMaterialName(dataJson.getString("MAKTX"));
DO.setBlineGroup(dataJson.getString("PLNAL"));
DO.setGroupCount(dataJson.getLong("PLNNR"));
DO.setBlineDescription(dataJson.getString("KTEXT"));
DO.setUom(dataJson.getString("PLNME"));
DO.setUseDescription(dataJson.getString("VERWE"));
DO.setStatus(dataJson.getString("STATU"));
String number = DO.getFactoryNumber() + "-" + DO.getMaterialNumber() + "-" + DO.getBlineGroup();
DO.setFactoryNumber(dataJson.getString("WERKS").trim());
DO.setMaterialNumber(dataJson.getString("MATNR").trim());
DO.setMaterialName(dataJson.getString("MAKTX").trim());
DO.setBlineGroup(dataJson.getString("PLNAL").trim());
Long groupCount = null;
String plnnrStr = dataJson.getString("PLNNR");
if (plnnrStr != null && !plnnrStr.trim().isEmpty()) {
try {
groupCount = Long.valueOf(plnnrStr.trim());
} catch (NumberFormatException e) {
log.error("转换PLNNR为Long类型失败: " + plnnrStr, e);
}
}
DO.setGroupCount(groupCount);
DO.setBlineDescription(dataJson.getString("KTEXT").trim());
DO.setUom(dataJson.getString("PLNME").trim());
DO.setUseDescription(dataJson.getString("VERWE").trim());
DO.setStatus(dataJson.getString("STATU").trim());
String number = DO.getFactoryNumber() + "-" + DO.getMaterialNumber() + "-" + DO.getBlineGroup().trim()+"-" + DO.getGroupCount();
dataArrayNumbers.add(number);
if (numbers.get(number) != null) {
// 更新
@@ -271,7 +274,7 @@ public class ErpProcessServiceImpl implements ErpProcessService {
List<ErpProcessDO> bomList = erpProcessMapper.selectList(new LambdaQueryWrapperX<ErpProcessDO>());
Map<String, Long> existingNumbers = new HashMap<>();
for (ErpProcessDO bom : bomList) {
String mapKey = bom.getFactoryNumber() + "-" + bom.getMaterialNumber() + "-" + bom.getBlineGroup();
String mapKey = bom.getFactoryNumber() + "-" + bom.getMaterialNumber() + "-" + bom.getBlineGroup()+"-" + bom.getGroupCount();
existingNumbers.put(mapKey, bom.getId());
}
myRedisConfig.addRedisCacheMap(key, existingNumbers);

View File

@@ -183,49 +183,43 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
@Transactional
@XxlJob("getErpProductiveOrderTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产订单;
String funcnr = funcnrEnum.getFuncnr();
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产订单;
String funcnr = funcnrEnum.getFuncnr();
Map<String, Object> req = new HashMap<>();
List<Map<String, String>> datumList = new ArrayList<>();
Map<String, String> datumEntry = new HashMap<>();
// 构建datum参数数组
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();
List<String> redisCache = myRedisConfig.getRedisCache(OftenEnum.FuncnrEnum.工厂信息.getFuncnr());
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache) {
req.put("WERKS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
Map<String, Object> req = new HashMap<>();
List<Map<String, String>> datumList = new ArrayList<>();
Map<String, String> datumEntry = new HashMap<>();
// 构建datum参数数组
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();
List<String> redisCache = myRedisConfig.getRedisCache(OftenEnum.FuncnrEnum.工厂信息.getFuncnr());
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache) {
req.put("WERKS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
}
/**

View File

@@ -74,12 +74,12 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
}
@Override
public void deleteErpProductiveVersionListByIds(List<Long> ids) {
public void deleteErpProductiveVersionListByIds(List<Long> ids) {
// 校验存在
validateErpProductiveVersionExists(ids);
// 删除
erpProductiveVersionMapper.deleteByIds(ids);
}
}
private void validateErpProductiveVersionExists(List<Long> ids) {
List<ErpProductiveVersionDO> list = erpProductiveVersionMapper.selectByIds(ids);
@@ -108,47 +108,41 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
@Transactional
@XxlJob("getErpProductiveVersionTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.生产版本;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("WERKS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产版本;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("WERKS", number);
// 1. 调用ERP接口获取数据
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);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -165,15 +159,17 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
JSONObject dataJson = dataArray.getJSONObject(i);
if (dataJson != null) {
ErpProductiveVersionDO DO = new ErpProductiveVersionDO();
DO.setFactoryNumber(dataJson.getString("MATNR").trim());
DO.setMaterialNumber(dataJson.getString("WERKS").trim());
DO.setProductiveVersionNumber(dataJson.getString("VERID").trim());
DO.setFactoryNumber(dataJson.getString("MATNR") != null ? dataJson.getString("MATNR").trim() : null);
DO.setMaterialNumber(dataJson.getString("WERKS") != null ? dataJson.getString("WERKS").trim() : null);
DO.setProductiveVersionNumber(dataJson.getString("VERID") != null ? dataJson.getString("VERID").trim() : null);
DO.setProductiveVersionName(dataJson.getString("TEXT1"));
DO.setBomNumber(dataJson.getString("STLAL"));
DO.setBlineGroup(dataJson.getString("PLNNR"));
DO.setGroupCount(Long.valueOf(dataJson.getString("ALNAL").trim()));
String number = dataJson.getString("MATNR").trim()+"-"+dataJson.getString("WERKS").trim()+"-"+dataJson.getString("VERID").trim();
if (numbers.get(number)!=null) {
String alnalValue = dataJson.getString("ALNAL");
// 修复:增加对空字符串的判断
DO.setGroupCount(alnalValue != null && !alnalValue.trim().isEmpty() ? Long.valueOf(alnalValue.trim()) : null);
String number = dataJson.getString("MATNR").trim() + "-" + dataJson.getString("WERKS").trim() + "-" + dataJson.getString("VERID").trim();
if (numbers.get(number) != null) {
// 更新
DO.setId(numbers.get(number));
toUpdate.add(DO);
@@ -188,11 +184,11 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
Map<String, Long> deleteNumbers = new HashMap<>();
for (String number : numbers.keySet()) {
if (!dataArrayNumbers.contains(number)) {
deleteNumbers.put(number,numbers.get(number));
deleteNumbers.put(number, numbers.get(number));
}
}
return new ProcessingResult(toUpdate, toInsert,key,deleteNumbers);
return new ProcessingResult(toUpdate, toInsert, key, deleteNumbers);
}
/**
@@ -210,13 +206,13 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
.in(ErpProductiveVersionDO::getProductiveVersionNumber, result.toInsert.stream().map(ErpProductiveVersionDO::getProductiveVersionNumber).collect(Collectors.toList()))
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(asset -> asset.getFactoryNumber() + "-" + asset.getMaterialNumber()+ "-" + asset.getProductiveVersionNumber(), ErpProductiveVersionDO::getId));
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
.collect(Collectors.toMap(asset -> asset.getFactoryNumber() + "-" + asset.getMaterialNumber() + "-" + asset.getProductiveVersionNumber(), ErpProductiveVersionDO::getId));
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
if (!result.toUpdate.isEmpty()) {
erpProductiveVersionMapper.updateBatch(result.toUpdate);
}
if (!result.deleteNumbers.isEmpty()){
if (!result.deleteNumbers.isEmpty()) {
// 使用流式处理和批处理优化删除逻辑
List<Long> idsToDelete = new ArrayList<>(result.deleteNumbers.values());
erpProductiveVersionMapper.deleteByIds(idsToDelete);
@@ -233,7 +229,7 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
private final String key;
private final Map<String, Long> deleteNumbers;
public ProcessingResult(List<ErpProductiveVersionDO> toUpdate, List<ErpProductiveVersionDO> toInsert,String key,Map<String, Long> deleteNumbers) {
public ProcessingResult(List<ErpProductiveVersionDO> toUpdate, List<ErpProductiveVersionDO> toInsert, String key, Map<String, Long> deleteNumbers) {
this.toUpdate = toUpdate;
this.toInsert = toInsert;
this.key = key;

View File

@@ -74,12 +74,12 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
}
@Override
public void deleteErpPurchaseOrganizationListByIds(List<Long> ids) {
public void deleteErpPurchaseOrganizationListByIds(List<Long> ids) {
// 校验存在
validateErpPurchaseOrganizationExists(ids);
// 删除
erpPurchaseOrganizationMapper.deleteByIds(ids);
}
}
private void validateErpPurchaseOrganizationExists(List<Long> ids) {
List<ErpPurchaseOrganizationDO> list = erpPurchaseOrganizationMapper.selectByIds(ids);
@@ -108,55 +108,49 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
@Transactional
@XxlJob("getErpPurchaseOrganizationTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.采购组织;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
initializeMap(key);
}
Map<String, Object> req = new HashMap<>();
JSONArray dataArrayALL = new JSONArray();
// String factKey ="erpMap"+ OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
String factKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray == null || dataArray.isEmpty()) {
continue;
}
// 往每个子项中添加BUKRS字段
for (int j = 0; j < dataArray.size(); j++) {
JSONObject item = dataArray.getJSONObject(j);
if (item != null) {
item.put("BUKRS", number);
}
}
dataArrayALL.addAll(dataArray);
}
if (dataArrayALL.isEmpty()){
throw exception(ERP_PURCHASE_ORGANIZATION_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.采购组织;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
initializeMap(key);
}
Map<String, Object> req = new HashMap<>();
JSONArray dataArrayALL = new JSONArray();
// String factKey ="erpMap"+ OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
String factKey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray == null || dataArray.isEmpty()) {
continue;
}
// 往每个子项中添加BUKRS字段
for (int j = 0; j < dataArray.size(); j++) {
JSONObject item = dataArray.getJSONObject(j);
if (item != null) {
item.put("BUKRS", number);
}
}
dataArrayALL.addAll(dataArray);
}
if (dataArrayALL.isEmpty()) {
throw exception(ERP_PURCHASE_ORGANIZATION_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -177,7 +171,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
DO.setName(dataJson.getString("EKOTX"));
DO.setNumber(number);
DO.setCompanyNumber(dataJson.getString("BUKRS"));
if (numbers.get(number)!=null) {
if (numbers.get(number) != null) {
// 更新
DO.setId(numbers.get(number));
toUpdate.add(DO);
@@ -196,7 +190,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
}
}
return new ProcessingResult(toUpdate, toInsert,key,deleteNumbers);
return new ProcessingResult(toUpdate, toInsert, key, deleteNumbers);
}
/**
@@ -216,12 +210,12 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(ErpPurchaseOrganizationDO::getNumber, ErpPurchaseOrganizationDO::getId));
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
if (!result.toUpdate.isEmpty()) {
erpPurchaseOrganizationMapper.updateBatch(result.toUpdate);
}
if (!result.deleteNumbers.isEmpty()){
if (!result.deleteNumbers.isEmpty()) {
// 使用 in 条件批量删除,提高删除效率
erpPurchaseOrganizationMapper.delete(new LambdaQueryWrapperX<ErpPurchaseOrganizationDO>().in(ErpPurchaseOrganizationDO::getNumber, result.deleteNumbers));
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
@@ -237,7 +231,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
private final String key;
private final List<String> deleteNumbers;
public ProcessingResult(List<ErpPurchaseOrganizationDO> toUpdate, List<ErpPurchaseOrganizationDO> toInsert,String key,List<String> deleteNumbers) {
public ProcessingResult(List<ErpPurchaseOrganizationDO> toUpdate, List<ErpPurchaseOrganizationDO> toInsert, String key, List<String> deleteNumbers) {
this.toUpdate = toUpdate;
this.toInsert = toInsert;
this.key = key;

View File

@@ -74,12 +74,12 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
}
@Override
public void deleteErpSalesOrganizationListByIds(List<Long> ids) {
public void deleteErpSalesOrganizationListByIds(List<Long> ids) {
// 校验存在
validateErpSalesOrganizationExists(ids);
// 删除
erpSalesOrganizationMapper.deleteByIds(ids);
}
}
private void validateErpSalesOrganizationExists(List<Long> ids) {
List<ErpSalesOrganizationDO> list = erpSalesOrganizationMapper.selectByIds(ids);
@@ -108,54 +108,48 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
@Transactional
@XxlJob("getErpSalesOrganizationTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.销售组织;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray == null || dataArray.isEmpty()) {
continue;
}
// 往每个子项中添加BUKRS字段
for (int j = 0; j < dataArray.size(); j++) {
JSONObject item = dataArray.getJSONObject(j);
if (item != null) {
item.put("BUKRS", number);
}
}
dataArrayALL.addAll(dataArray);
}
if (dataArrayALL.isEmpty()){
throw exception(ERP_SALES_ORGANIZATION_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.销售组织;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("BUKRS", number);
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray == null || dataArray.isEmpty()) {
continue;
}
// 往每个子项中添加BUKRS字段
for (int j = 0; j < dataArray.size(); j++) {
JSONObject item = dataArray.getJSONObject(j);
if (item != null) {
item.put("BUKRS", number);
}
}
dataArrayALL.addAll(dataArray);
}
if (dataArrayALL.isEmpty()) {
throw exception(ERP_SALES_ORGANIZATION_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
// 3. 批量保存数据
saveData(result);
}
/**
@@ -176,7 +170,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
DO.setName(dataJson.getString("VTEXT"));
DO.setNumber(number);
DO.setCompanyNumber(dataJson.getString("BUKRS"));
if (numbers.get(number)!=null) {
if (numbers.get(number) != null) {
// 更新
DO.setId(numbers.get(number));
toUpdate.add(DO);
@@ -184,7 +178,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
// 新增
toInsert.add(DO);
}
dataArrayNumbers.add( number);
dataArrayNumbers.add(number);
}
}
// 过滤出numbers中有但dataArray中KOSTL没有的记录即为需要删除的数据
@@ -194,7 +188,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
deleteNumbers.add(number);
}
}
return new ProcessingResult(toUpdate, toInsert,key,deleteNumbers);
return new ProcessingResult(toUpdate, toInsert, key, deleteNumbers);
}
/**
@@ -214,7 +208,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(ErpSalesOrganizationDO::getNumber, ErpSalesOrganizationDO::getId));
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
if (!result.toUpdate.isEmpty()) {
erpSalesOrganizationMapper.updateBatch(result.toUpdate);
@@ -235,7 +229,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
private final String key;
private final List<String> deleteNumbers;
public ProcessingResult(List<ErpSalesOrganizationDO> toUpdate, List<ErpSalesOrganizationDO> toInsert,String key,List<String> deleteNumbers) {
public ProcessingResult(List<ErpSalesOrganizationDO> toUpdate, List<ErpSalesOrganizationDO> toInsert, String key, List<String> deleteNumbers) {
this.toUpdate = toUpdate;
this.toInsert = toInsert;
this.key = key;

View File

@@ -169,54 +169,48 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
@Transactional
@XxlJob("getErpWarehouseTask")
public void callErpRfcInterface() {
try {
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.库位信息;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("WERKS", number);
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray == null || dataArray.isEmpty()) {
continue;
}
// 往每个子项中添加BUKRS字段
for (int j = 0; j < dataArray.size(); j++) {
JSONObject item = dataArray.getJSONObject(j);
if (item != null) {
item.put("WERKS", number);
}
}
dataArrayALL.addAll(dataArray);
}
if (dataArrayALL.isEmpty()) {
throw exception(ERP_WAREHOUSE_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
// 3. 批量保存数据
saveData(result);
} catch (Exception e) {
log.error("调用ERP RFC接口失败: {}", e);
throw new RuntimeException("调用ERP RFC接口失败: " + e.getMessage(), e);
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.库位信息;
String funcnr = funcnrEnum.getFuncnr();
//防止缓存数据丢失
String key = "erpMap" + funcnrEnum.getFuncnr();
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 = myRedisConfig.getRedisCacheMap(factKey);
if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
// 1. 调用ERP接口获取数据
for (String number : redisCache.keySet()) {
req.put("WERKS", number);
// 1. 调用ERP接口获取数据
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
if (dataArray == null || dataArray.isEmpty()) {
continue;
}
// 往每个子项中添加BUKRS字段
for (int j = 0; j < dataArray.size(); j++) {
JSONObject item = dataArray.getJSONObject(j);
if (item != null) {
item.put("WERKS", number);
}
}
dataArrayALL.addAll(dataArray);
}
if (dataArrayALL.isEmpty()) {
throw exception(ERP_WAREHOUSE_NOT_EXISTS);
}
// 2. 处理公司数据,区分新增和更新
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
// 3. 批量保存数据
saveData(result);
}
/**