Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -1,13 +1,23 @@
|
|||||||
FROM 172.16.46.66:10043/base-service/eclipse-temurin:21-jre
|
ARG BASE_IMAGE=172.16.46.66:10043/base-service/skywalking-agent-jre:9.7.0
|
||||||
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
# 设置应用目录
|
# 设置应用目录
|
||||||
|
RUN mkdir -p /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 复制应用文件
|
# 复制应用文件
|
||||||
COPY target/base-server.jar /app/base-server.jar
|
COPY target/base-server.jar app.jar
|
||||||
|
|
||||||
|
# 设置环境变量
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
ENV JAVA_OPTS="-Xms512m -Xmx512m"
|
||||||
|
ENV SW_AGENT_HOME=/opt/skywalking/agent
|
||||||
|
ENV SW_AGENT_NAME=base-server
|
||||||
|
ENV SW_AGENT_COLLECTOR_BACKEND_SERVICES=172.16.46.63:30201
|
||||||
|
ENV AGENT_JAVA_OPTS="-javaagent:${SW_AGENT_HOME}/skywalking-agent.jar -Dskywalking.agent.service_name=${SW_AGENT_NAME} -Dskywalking.collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES}"
|
||||||
|
|
||||||
# 暴露端口
|
# 暴露端口
|
||||||
EXPOSE 48200
|
EXPOSE 48200
|
||||||
|
|
||||||
# 运行应用
|
# 运行应用
|
||||||
ENTRYPOINT ["java", "-jar", "/app/base-server.jar"]
|
CMD java ${AGENT_JAVA_OPTS} ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode DEPARTMENT_MATERIAL_NOT_EXISTS = new ErrorCode(1_027_101_004, "组织物料不存在");
|
ErrorCode DEPARTMENT_MATERIAL_NOT_EXISTS = new ErrorCode(1_027_101_004, "组织物料不存在");
|
||||||
ErrorCode MATERIAL_HAS_CLASSES_NOT_EXISTS = new ErrorCode(1_027_101_004, "物料持有属性不存在");
|
ErrorCode MATERIAL_HAS_CLASSES_NOT_EXISTS = new ErrorCode(1_027_101_004, "物料持有属性不存在");
|
||||||
|
|
||||||
|
ErrorCode MATERIAL_CLASSES_HIERARCHY_INVALID = new ErrorCode(1_027_101_101, "物料分类层级不符合 1-2-3 的层级规则");
|
||||||
|
ErrorCode MATERIAL_CLASSES_PARENT_NOT_EXISTS = new ErrorCode(1_027_101_102, "上级物料分类不存在");
|
||||||
|
ErrorCode MATERIAL_CLASSES_MAX_LEVEL_EXCEEDED = new ErrorCode(1_027_101_103, "物料分类最多支持三级");
|
||||||
|
ErrorCode MATERIAL_CLASSES_LEVEL_CONFLICT_WITH_CHILDREN = new ErrorCode(1_027_101_104, "存在下级分类,无法调整当前分类层级");
|
||||||
|
ErrorCode MATERIAL_CLASSES_LEVEL3_REQUIRED_FOR_MATERIAL = new ErrorCode(1_027_101_105, "仅允许三级物料分类关联物料");
|
||||||
|
|
||||||
// ========== 工艺信息属性 ==========
|
// ========== 工艺信息属性 ==========
|
||||||
ErrorCode PROCESSING_INFOMATION_NOT_EXISTS = new ErrorCode(1_027_101_005, "工艺信息不存在");
|
ErrorCode PROCESSING_INFOMATION_NOT_EXISTS = new ErrorCode(1_027_101_005, "工艺信息不存在");
|
||||||
ErrorCode PROCESSING_INFOMATION_OPERATION_NOT_EXISTS = new ErrorCode(1_027_101_006, "工艺工序不存在");
|
ErrorCode PROCESSING_INFOMATION_OPERATION_NOT_EXISTS = new ErrorCode(1_027_101_006, "工艺工序不存在");
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import com.zt.plat.framework.common.pojo.CommonResult;
|
|||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
|
||||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimplePageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimpleRespVO;
|
||||||
import com.zt.plat.module.base.service.base.MaterialInfomationService;
|
import com.zt.plat.module.base.service.base.MaterialInfomationService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -76,16 +76,23 @@ public class MaterialInfomationController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
||||||
public CommonResult<MaterialInfomationRespVO> getMaterialInfomation(@RequestParam("id") Long id) {
|
public CommonResult<MaterialInfomationRespVO> getMaterialInfomation(@RequestParam("id") Long id) {
|
||||||
MaterialInfomationDO materialInfomation = materialInfomationService.getMaterialInfomation(id);
|
MaterialInfomationRespVO materialInfomation = materialInfomationService.getMaterialInfomation(id);
|
||||||
return success(BeanUtils.toBean(materialInfomation, MaterialInfomationRespVO.class));
|
return success(materialInfomation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得物料信息分页")
|
@Operation(summary = "获得物料信息分页")
|
||||||
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
||||||
public CommonResult<PageResult<MaterialInfomationRespVO>> getMaterialInfomationPage(@Valid MaterialInfomationPageReqVO pageReqVO) {
|
public CommonResult<PageResult<MaterialInfomationRespVO>> getMaterialInfomationPage(@Valid MaterialInfomationPageReqVO pageReqVO) {
|
||||||
PageResult<MaterialInfomationDO> pageResult = materialInfomationService.getMaterialInfomationPage(pageReqVO);
|
PageResult<MaterialInfomationRespVO> pageResult = materialInfomationService.getMaterialInfomationPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, MaterialInfomationRespVO.class));
|
return success(pageResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/simple-page")
|
||||||
|
@Operation(summary = "获得物料信息精简分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
||||||
|
public CommonResult<PageResult<MaterialInfomationSimpleRespVO>> getMaterialInfomationSimplePage(@Valid MaterialInfomationSimplePageReqVO pageReqVO) {
|
||||||
|
return success(materialInfomationService.getMaterialInfomationSimplePage(pageReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@@ -95,10 +102,10 @@ public class MaterialInfomationController {
|
|||||||
public void exportMaterialInfomationExcel(@Valid MaterialInfomationPageReqVO pageReqVO,
|
public void exportMaterialInfomationExcel(@Valid MaterialInfomationPageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<MaterialInfomationDO> list = materialInfomationService.getMaterialInfomationPage(pageReqVO).getList();
|
List<MaterialInfomationRespVO> list = materialInfomationService.getMaterialInfomationPage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "物料信息.xls", "数据", MaterialInfomationRespVO.class,
|
ExcelUtils.write(response, "物料信息.xls", "数据", MaterialInfomationRespVO.class,
|
||||||
BeanUtils.toBean(list, MaterialInfomationRespVO.class));
|
list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getOneTest")
|
@GetMapping("/getOneTest")
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.base.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料信息精简分页 Request VO
|
||||||
|
*/
|
||||||
|
@Schema(description = "管理后台 - 物料信息精简分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class MaterialInfomationSimplePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "关键字(编码/名称模糊匹配)")
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
@Schema(description = "分类 ID")
|
||||||
|
private Long classesId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.base.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精简的物料信息 Response VO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MaterialInfomationSimpleRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "物料信息ID", example = "1024")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "物料编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "物料名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "分类ID")
|
||||||
|
private Long classesId;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -116,4 +116,12 @@ public class BusinessDictionaryTypeController implements BusinessControllerMarke
|
|||||||
return success(businessDictionaryTypeService.getBusinessDictionaryDataListByDictionaryTypeId(dictionaryTypeId));
|
return success(businessDictionaryTypeService.getBusinessDictionaryDataListByDictionaryTypeId(dictionaryTypeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/business-dictionary-data/list-by-type")
|
||||||
|
@Operation(summary = "根据字典类型编码获取业务字典数据列表")
|
||||||
|
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:query')")
|
||||||
|
public CommonResult<List<BusinessDictionaryDataDO>> getBusinessDictionaryDataListByType(@RequestParam("type") String type) {
|
||||||
|
// 通过类型编码直接获取对应的业务字典项,避免前端重复查询字典类型 ID
|
||||||
|
return success(businessDictionaryTypeService.getBusinessDictionaryDataListByType(type));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@ import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
|||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
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 static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||||
@@ -79,8 +78,8 @@ public class DepartmentMaterialController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('base:department-material:query')")
|
@PreAuthorize("@ss.hasPermission('base:department-material:query')")
|
||||||
public CommonResult<DepartmentMaterialRespVO> getDepartmentMaterial(@RequestParam("id") Long id) {
|
public CommonResult<DepartmentMaterialRespVO> getDepartmentMaterial(@RequestParam("id") Long id) {
|
||||||
DepartmentMaterialDO departmentMaterial = departmentMaterialService.getDepartmentMaterial(id);
|
DepartmentMaterialRespVO departmentMaterial = departmentMaterialService.getDepartmentMaterial(id);
|
||||||
return success(BeanUtils.toBean(departmentMaterial, DepartmentMaterialRespVO.class));
|
return success(departmentMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public class DepartmentMaterialPageReqVO extends PageParam {
|
|||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
@Schema(description = "状态编码", example = "1")
|
@Schema(description = "状态编码", example = "1")
|
||||||
private String isEnable;
|
// 对应系统字典 base_material_status,用于前端筛选
|
||||||
|
private String status;
|
||||||
|
|
||||||
@Schema(description = "物料编码")
|
@Schema(description = "物料编码")
|
||||||
private String materialNumber;
|
private String materialNumber;
|
||||||
|
|||||||
@@ -74,10 +74,7 @@ public class DepartmentMaterialRespVO {
|
|||||||
|
|
||||||
@Schema(description = "状态编码")
|
@Schema(description = "状态编码")
|
||||||
@ExcelProperty("状态编码")
|
@ExcelProperty("状态编码")
|
||||||
private String isEnable;
|
// base_material_status 系统字典取值
|
||||||
|
private String status;
|
||||||
@Schema(description = "状态名称")
|
|
||||||
@ExcelProperty("状态")
|
|
||||||
private String statusLabel;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,10 @@ public class DepartmentMaterialSaveReqVO {
|
|||||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5674")
|
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5674")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
|
||||||
|
@NotNull(message = "部门ID不能为空")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
@Schema(description = "物料信息ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3923")
|
@Schema(description = "物料信息ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3923")
|
||||||
@NotNull(message = "物料信息ID不能为空")
|
@NotNull(message = "物料信息ID不能为空")
|
||||||
private Long infomationId;
|
private Long infomationId;
|
||||||
@@ -23,6 +27,11 @@ public class DepartmentMaterialSaveReqVO {
|
|||||||
@NotEmpty(message = "字典数据值-物料类型不能为空")
|
@NotEmpty(message = "字典数据值-物料类型不能为空")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
|
@Schema(description = "状态编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
// 对应系统字典 base_material_status
|
||||||
|
@NotEmpty(message = "状态不能为空")
|
||||||
|
private String status;
|
||||||
|
|
||||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotEmpty(message = "备注不能为空")
|
@NotEmpty(message = "备注不能为空")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.zt.plat.module.base.controller.admin.materialproperties;
|
package com.zt.plat.module.base.controller.admin.materialproperties;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -19,7 +21,6 @@ import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
|||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
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 static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||||
@@ -28,7 +29,6 @@ import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
|||||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
|
||||||
import com.zt.plat.module.base.service.materialproperties.MaterialPropertiesService;
|
import com.zt.plat.module.base.service.materialproperties.MaterialPropertiesService;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 物料属性")
|
@Tag(name = "管理后台 - 物料属性")
|
||||||
@@ -79,16 +79,23 @@ public class MaterialPropertiesController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('base:material-properties:query')")
|
@PreAuthorize("@ss.hasPermission('base:material-properties:query')")
|
||||||
public CommonResult<MaterialPropertiesRespVO> getMaterialProperties(@RequestParam("id") Long id) {
|
public CommonResult<MaterialPropertiesRespVO> getMaterialProperties(@RequestParam("id") Long id) {
|
||||||
MaterialPropertiesDO materialProperties = materialPropertiesService.getMaterialProperties(id);
|
MaterialPropertiesRespVO materialProperties = materialPropertiesService.getMaterialProperties(id);
|
||||||
return success(BeanUtils.toBean(materialProperties, MaterialPropertiesRespVO.class));
|
return success(materialProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得物料属性分页")
|
@Operation(summary = "获得物料属性分页")
|
||||||
@PreAuthorize("@ss.hasPermission('base:material-properties:query')")
|
@PreAuthorize("@ss.hasPermission('base:material-properties:query')")
|
||||||
public CommonResult<PageResult<MaterialPropertiesRespVO>> getMaterialPropertiesPage(@Valid MaterialPropertiesPageReqVO pageReqVO) {
|
public CommonResult<PageResult<MaterialPropertiesRespVO>> getMaterialPropertiesPage(@Valid MaterialPropertiesPageReqVO pageReqVO) {
|
||||||
PageResult<MaterialPropertiesDO> pageResult = materialPropertiesService.getMaterialPropertiesPage(pageReqVO);
|
PageResult<MaterialPropertiesRespVO> pageResult = materialPropertiesService.getMaterialPropertiesPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, MaterialPropertiesRespVO.class));
|
return success(pageResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/simple-page")
|
||||||
|
@Operation(summary = "获得物料属性精简分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('base:material-properties:query')")
|
||||||
|
public CommonResult<PageResult<MaterialPropertiesSimpleRespVO>> getMaterialPropertiesSimplePage(@Valid MaterialPropertiesSimplePageReqVO pageReqVO) {
|
||||||
|
return success(materialPropertiesService.getMaterialPropertiesSimplePage(pageReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@@ -98,10 +105,10 @@ public class MaterialPropertiesController {
|
|||||||
public void exportMaterialPropertiesExcel(@Valid MaterialPropertiesPageReqVO pageReqVO,
|
public void exportMaterialPropertiesExcel(@Valid MaterialPropertiesPageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<MaterialPropertiesDO> list = materialPropertiesService.getMaterialPropertiesPage(pageReqVO).getList();
|
List<MaterialPropertiesRespVO> list = materialPropertiesService.getMaterialPropertiesPage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "物料属性.xls", "数据", MaterialPropertiesRespVO.class,
|
ExcelUtils.write(response, "物料属性.xls", "数据", MaterialPropertiesRespVO.class,
|
||||||
BeanUtils.toBean(list, MaterialPropertiesRespVO.class));
|
list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,10 +19,13 @@ public class MaterialPropertiesPageReqVO extends PageParam {
|
|||||||
@Schema(description = "属性名称", example = "芋艿")
|
@Schema(description = "属性名称", example = "芋艿")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "关键字(编码/名称模糊匹配)")
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
@Schema(description = "计量单位量ID", example = "30468")
|
@Schema(description = "计量单位量ID", example = "30468")
|
||||||
private Long unitQuantityId;
|
private Long unitQuantityId;
|
||||||
|
|
||||||
@Schema(description = "业务字典数据值")
|
@Schema(description = "属性类型")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
@Schema(description = "数据类型", example = "1")
|
@Schema(description = "数据类型", example = "1")
|
||||||
|
|||||||
@@ -28,10 +28,14 @@ public class MaterialPropertiesRespVO {
|
|||||||
@ExcelProperty("计量单位量ID")
|
@ExcelProperty("计量单位量ID")
|
||||||
private Long unitQuantityId;
|
private Long unitQuantityId;
|
||||||
|
|
||||||
@Schema(description = "业务字典数据值", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "属性类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("业务字典数据值")
|
@ExcelProperty("属性类型")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
|
@Schema(description = "属性类型名称")
|
||||||
|
@ExcelProperty("属性类型名称")
|
||||||
|
private String dictionaryDataLabel;
|
||||||
|
|
||||||
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@ExcelProperty("数据类型")
|
@ExcelProperty("数据类型")
|
||||||
private String dataType;
|
private String dataType;
|
||||||
@@ -40,6 +44,18 @@ public class MaterialPropertiesRespVO {
|
|||||||
@ExcelProperty("备注")
|
@ExcelProperty("备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "量纲名称")
|
||||||
|
@ExcelProperty("量纲名称")
|
||||||
|
private String unitQuantityName;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位名称")
|
||||||
|
@ExcelProperty("计量单位")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位符号")
|
||||||
|
@ExcelProperty("计量单位符号")
|
||||||
|
private String unitSymbol;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ public class MaterialPropertiesSaveReqVO {
|
|||||||
@NotEmpty(message = "属性名称不能为空")
|
@NotEmpty(message = "属性名称不能为空")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "计量单位量ID", example = "30468")
|
@Schema(description = "计量单位量ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "30468")
|
||||||
private Long unitQuantityId;
|
private Long unitQuantityId;
|
||||||
|
|
||||||
@Schema(description = "业务字典数据值", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "属性类型(业务字典数据值)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotEmpty(message = "业务字典数据值不能为空")
|
@NotEmpty(message = "属性类型不能为空")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.materialproperties.vo;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 物料属性精简分页 Request VO")
|
||||||
|
@Data
|
||||||
|
public class MaterialPropertiesSimplePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "关键字(编码/名称模糊匹配)")
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
@Schema(description = "属性类型")
|
||||||
|
private String dictionaryDataValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.materialproperties.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精简的物料属性 Response VO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MaterialPropertiesSimpleRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "物料属性ID", example = "1001")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "属性编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "属性名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "数据类型")
|
||||||
|
private String dataType;
|
||||||
|
|
||||||
|
@Schema(description = "单位名称")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
@Schema(description = "单位符号")
|
||||||
|
private String unitSymbol;
|
||||||
|
|
||||||
|
@Schema(description = "属性类型")
|
||||||
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
|
@Schema(description = "属性类型名称")
|
||||||
|
private String dictionaryDataLabel;
|
||||||
|
}
|
||||||
@@ -91,6 +91,13 @@ public class QuantityUnitRelationController implements BusinessControllerMarker
|
|||||||
return success(BeanUtils.toBean(pageResult, QuantityUnitRelationRespVO.class));
|
return success(BeanUtils.toBean(pageResult, QuantityUnitRelationRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/simple-page")
|
||||||
|
@Operation(summary = "获得计量单位量与单位关联精简分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:query')")
|
||||||
|
public CommonResult<PageResult<QuantityUnitRelationSimpleRespVO>> getQuantityUnitRelationSimplePage(@Valid QuantityUnitRelationSimplePageReqVO pageReqVO) {
|
||||||
|
return success(quantityUnitRelationService.getQuantityUnitRelationSimplePage(pageReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@Operation(summary = "导出计量单位量与单位关联 Excel")
|
@Operation(summary = "导出计量单位量与单位关联 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:export')")
|
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:export')")
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计量单位量与单位关联精简分页 Request VO
|
||||||
|
*/
|
||||||
|
@Schema(description = "管理后台 - 计量单位量与单位关联精简分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class QuantityUnitRelationSimplePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "量纲ID")
|
||||||
|
private Long untQtyId;
|
||||||
|
|
||||||
|
@Schema(description = "关键字(量纲/单位名称、符号模糊匹配)")
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精简的量纲-单位关联响应
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QuantityUnitRelationSimpleRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "关联关系ID", example = "1001")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "量纲ID", example = "2001")
|
||||||
|
private Long untQtyId;
|
||||||
|
|
||||||
|
@Schema(description = "量纲名称")
|
||||||
|
private String untQtyName;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位ID", example = "3001")
|
||||||
|
private Long untId;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位名称")
|
||||||
|
private String untName;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位符号")
|
||||||
|
private String untSymbol;
|
||||||
|
|
||||||
|
@Schema(description = "是否基准单位:1表示是,0表示否")
|
||||||
|
private Integer isBse;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import com.zt.plat.module.base.controller.admin.templtp.onlyoffice.service.OnlyO
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.security.PermitAll;
|
import jakarta.annotation.security.PermitAll;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/base/onlyoffice")
|
@RequestMapping("/base/onlyoffice")
|
||||||
@Tag(name = "管理后台 - onlyOffice回调")
|
@Tag(name = "管理后台 - onlyOffice回调")
|
||||||
@@ -31,19 +33,21 @@ public class OnlyOfficeCallbackController {
|
|||||||
@PostMapping("/callback/{id}")
|
@PostMapping("/callback/{id}")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
@TenantIgnore
|
@TenantIgnore
|
||||||
public ResponseEntity<Map<String, Integer>> handleCallback(@RequestBody OnlyOfficeCallback callback, @PathVariable String id,@RequestParam("fileName") String fileName) {
|
public ResponseEntity<Map<String, Object>> handleCallback(@RequestBody OnlyOfficeCallback callback, @PathVariable String id,@RequestParam("fileName") String fileName) {
|
||||||
// 处理回调逻辑
|
// 处理回调逻辑
|
||||||
callbackService.processCallback(callback,id,fileName);
|
callbackService.processCallback(callback,id,fileName);
|
||||||
|
log.info("回调参数:【{}】",callback.toString());
|
||||||
// 返回必须的响应,否则OnlyOffice会显示错误
|
// 返回必须的响应,否则OnlyOffice会显示错误
|
||||||
Map<String, Integer> response = new HashMap<>();
|
Map<String, Object> response = new HashMap<>();
|
||||||
response.put("error", 0);
|
response.put("error", 0);
|
||||||
|
// response.put("version", 100);
|
||||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理OnlyOffice文档编辑服务发送的回调
|
* 处理OnlyOffice文档编辑服务发送的回调
|
||||||
*/
|
*/
|
||||||
@PostMapping("/contract /callback/{id}")
|
@PostMapping("/contract/callback/{id}")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
@TenantIgnore
|
@TenantIgnore
|
||||||
public ResponseEntity<Map<String, Integer>> handleContractCallback(@RequestBody OnlyOfficeCallback callback, @PathVariable String id,@RequestParam("fileName") String fileName) {
|
public ResponseEntity<Map<String, Integer>> handleContractCallback(@RequestBody OnlyOfficeCallback callback, @PathVariable String id,@RequestParam("fileName") String fileName) {
|
||||||
@@ -52,6 +56,7 @@ public class OnlyOfficeCallbackController {
|
|||||||
// 返回必须的响应,否则OnlyOffice会显示错误
|
// 返回必须的响应,否则OnlyOffice会显示错误
|
||||||
Map<String, Integer> response = new HashMap<>();
|
Map<String, Integer> response = new HashMap<>();
|
||||||
response.put("error", 0);
|
response.put("error", 0);
|
||||||
|
// response.put("version", 0);
|
||||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ public class OnlyOfficeCallbackServiceImpl implements OnlyOfficeCallbackService
|
|||||||
fileInfo.put("id",String.valueOf(fileRespDTO.getId()));
|
fileInfo.put("id",String.valueOf(fileRespDTO.getId()));
|
||||||
fileInfo.put("name", fileRespDTO.getName());
|
fileInfo.put("name", fileRespDTO.getName());
|
||||||
fileInfo.put("directory", fileRespDTO.getDirectory());
|
fileInfo.put("directory", fileRespDTO.getDirectory());
|
||||||
|
fileInfo.put("key", callback.getKey());
|
||||||
templateInstanceService.updateTemplateInstanceFileUrlByInstanceId(id, JSONObject.toJSONString(fileInfo));
|
templateInstanceService.updateTemplateInstanceFileUrlByInstanceId(id, JSONObject.toJSONString(fileInfo));
|
||||||
} else {
|
} else {
|
||||||
// 创建文件失败,处理错误
|
// 创建文件失败,处理错误
|
||||||
@@ -352,6 +353,7 @@ public class OnlyOfficeCallbackServiceImpl implements OnlyOfficeCallbackService
|
|||||||
fileInfo.put("id",String.valueOf(fileRespDTO.getId()));
|
fileInfo.put("id",String.valueOf(fileRespDTO.getId()));
|
||||||
fileInfo.put("name", fileRespDTO.getName());
|
fileInfo.put("name", fileRespDTO.getName());
|
||||||
fileInfo.put("directory", fileRespDTO.getDirectory());
|
fileInfo.put("directory", fileRespDTO.getDirectory());
|
||||||
|
fileInfo.put("key", callback.getKey());
|
||||||
templateInstanceService.updateTemplateInstanceFileUrlByInstanceId(id, JSONObject.toJSONString(fileInfo));
|
templateInstanceService.updateTemplateInstanceFileUrlByInstanceId(id, JSONObject.toJSONString(fileInfo));
|
||||||
} else {
|
} else {
|
||||||
// 创建文件失败,处理错误
|
// 创建文件失败,处理错误
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ public class TemplateInstanceDataRespVO {
|
|||||||
@ExcelProperty("主键")
|
@ExcelProperty("主键")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "字段名字", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("字段名字")
|
||||||
|
private String fldName;
|
||||||
|
|
||||||
@Schema(description = "关联实例主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25824")
|
@Schema(description = "关联实例主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25824")
|
||||||
@ExcelProperty("关联实例主键")
|
@ExcelProperty("关联实例主键")
|
||||||
private String inscId;
|
private String inscId;
|
||||||
@@ -24,6 +29,10 @@ public class TemplateInstanceDataRespVO {
|
|||||||
@ExcelProperty("字段标识;关联字段库")
|
@ExcelProperty("字段标识;关联字段库")
|
||||||
private String fldKy;
|
private String fldKy;
|
||||||
|
|
||||||
|
@Schema(description = "字段結構", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("字段結構;")
|
||||||
|
private String fldDoc;
|
||||||
|
|
||||||
@Schema(description = "用户填写的值", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "用户填写的值", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("用户填写的值")
|
@ExcelProperty("用户填写的值")
|
||||||
private String fldVal;
|
private String fldVal;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zt.plat.module.base.controller.admin.templtp.vo;
|
package com.zt.plat.module.base.controller.admin.templtp.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.zt.plat.module.base.dal.dao.businessdictionarytype;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -26,4 +28,16 @@ public interface BusinessDictionaryDataMapper extends BaseMapperX<BusinessDictio
|
|||||||
return deleteBatch(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeIds);
|
return deleteBatch(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<BusinessDictionaryDataDO> selectListByValues(Iterable<String> values) {
|
||||||
|
if (values == null || !values.iterator().hasNext()) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
List<String> valueList = CollUtil.newArrayList(values);
|
||||||
|
if (CollUtil.isEmpty(valueList)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return selectList(new LambdaQueryWrapperX<BusinessDictionaryDataDO>()
|
||||||
|
.in(BusinessDictionaryDataDO::getValue, valueList));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,4 +23,8 @@ public interface BusinessDictionaryTypeMapper extends BaseMapperX<BusinessDictio
|
|||||||
.orderByDesc(BusinessDictionaryTypeDO::getId));
|
.orderByDesc(BusinessDictionaryTypeDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default BusinessDictionaryTypeDO selectByType(String type) {
|
||||||
|
return selectOne(BusinessDictionaryTypeDO::getType, type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ public interface DepartmentMaterialMapper extends BaseMapperX<DepartmentMaterial
|
|||||||
.eqIfPresent(DepartmentMaterialDO::getClassesId, reqVO.getClassesId())
|
.eqIfPresent(DepartmentMaterialDO::getClassesId, reqVO.getClassesId())
|
||||||
.eqIfPresent(DepartmentMaterialDO::getDeptId, reqVO.getDeptId())
|
.eqIfPresent(DepartmentMaterialDO::getDeptId, reqVO.getDeptId())
|
||||||
.eqIfPresent(DepartmentMaterialDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
.eqIfPresent(DepartmentMaterialDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
||||||
|
.eqIfPresent(DepartmentMaterialDO::getStatus, reqVO.getStatus())
|
||||||
.eqIfPresent(DepartmentMaterialDO::getRemark, reqVO.getRemark())
|
.eqIfPresent(DepartmentMaterialDO::getRemark, reqVO.getRemark())
|
||||||
.betweenIfPresent(DepartmentMaterialDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(DepartmentMaterialDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(DepartmentMaterialDO::getId));
|
.orderByDesc(DepartmentMaterialDO::getId));
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.zt.plat.module.base.dal.dao.materialproperties;
|
package com.zt.plat.module.base.dal.dao.materialproperties;
|
||||||
|
|
||||||
import java.util.*;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
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.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesPageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSimplePageReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料属性 Mapper
|
* 物料属性 Mapper
|
||||||
@@ -18,15 +18,33 @@ import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
|||||||
public interface MaterialPropertiesMapper extends BaseMapperX<MaterialPropertiesDO> {
|
public interface MaterialPropertiesMapper extends BaseMapperX<MaterialPropertiesDO> {
|
||||||
|
|
||||||
default PageResult<MaterialPropertiesDO> selectPage(MaterialPropertiesPageReqVO reqVO) {
|
default PageResult<MaterialPropertiesDO> selectPage(MaterialPropertiesPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialPropertiesDO>()
|
LambdaQueryWrapperX<MaterialPropertiesDO> query = new LambdaQueryWrapperX<MaterialPropertiesDO>()
|
||||||
.eqIfPresent(MaterialPropertiesDO::getCode, reqVO.getCode())
|
.eqIfPresent(MaterialPropertiesDO::getCode, reqVO.getCode())
|
||||||
.likeIfPresent(MaterialPropertiesDO::getName, reqVO.getName())
|
.likeIfPresent(MaterialPropertiesDO::getName, reqVO.getName())
|
||||||
.eqIfPresent(MaterialPropertiesDO::getUnitQuantityId, reqVO.getUnitQuantityId())
|
.eqIfPresent(MaterialPropertiesDO::getUnitQuantityId, reqVO.getUnitQuantityId())
|
||||||
.eqIfPresent(MaterialPropertiesDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
.eqIfPresent(MaterialPropertiesDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
||||||
.eqIfPresent(MaterialPropertiesDO::getDataType, reqVO.getDataType())
|
.eqIfPresent(MaterialPropertiesDO::getDataType, reqVO.getDataType())
|
||||||
.eqIfPresent(MaterialPropertiesDO::getRemark, reqVO.getRemark())
|
.eqIfPresent(MaterialPropertiesDO::getRemark, reqVO.getRemark())
|
||||||
.betweenIfPresent(MaterialPropertiesDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(MaterialPropertiesDO::getCreateTime, reqVO.getCreateTime());
|
||||||
.orderByDesc(MaterialPropertiesDO::getId));
|
if (StrUtil.isNotBlank(reqVO.getKeyword())) {
|
||||||
|
query.and(w -> w.like(MaterialPropertiesDO::getCode, reqVO.getKeyword())
|
||||||
|
.or()
|
||||||
|
.like(MaterialPropertiesDO::getName, reqVO.getKeyword()));
|
||||||
|
}
|
||||||
|
query.orderByDesc(MaterialPropertiesDO::getId);
|
||||||
|
return selectPage(reqVO, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
default PageResult<MaterialPropertiesDO> selectSimplePage(MaterialPropertiesSimplePageReqVO reqVO) {
|
||||||
|
LambdaQueryWrapperX<MaterialPropertiesDO> query = new LambdaQueryWrapperX<MaterialPropertiesDO>()
|
||||||
|
.eqIfPresent(MaterialPropertiesDO::getDictionaryDataValue, reqVO.getDictionaryDataValue());
|
||||||
|
if (StrUtil.isNotBlank(reqVO.getKeyword())) {
|
||||||
|
query.and(w -> w.like(MaterialPropertiesDO::getCode, reqVO.getKeyword())
|
||||||
|
.or()
|
||||||
|
.like(MaterialPropertiesDO::getName, reqVO.getKeyword()));
|
||||||
|
}
|
||||||
|
query.orderByAsc(MaterialPropertiesDO::getCode);
|
||||||
|
return selectPage(reqVO, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
package com.zt.plat.module.base.dal.dao.quantityUnitRelation;
|
package com.zt.plat.module.base.dal.dao.quantityUnitRelation;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
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.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.QuantityUnitRelationPageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.QuantityUnitRelationSimplePageReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.*;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计量单位量与单位关联 Mapper
|
* 计量单位量与单位关联 Mapper
|
||||||
@@ -24,6 +25,10 @@ public interface QuantityUnitRelationMapper extends BaseMapperX<QuantityUnitRela
|
|||||||
.orderByDesc(QuantityUnitRelationDO::getUntQtyId));
|
.orderByDesc(QuantityUnitRelationDO::getUntQtyId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default PageResult<QuantityUnitRelationDO> selectSimplePage(QuantityUnitRelationSimplePageReqVO reqVO, LambdaQueryWrapperX<QuantityUnitRelationDO> wrapper) {
|
||||||
|
return BaseMapperX.super.selectPage(reqVO, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据量纲ID查询所有关联关系
|
* 根据量纲ID查询所有关联关系
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ public class DepartmentMaterialDO extends BaseDO {
|
|||||||
@TableField("DIC_DAT_VAL")
|
@TableField("DIC_DAT_VAL")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
/**
|
/**
|
||||||
|
* 状态编码,对应系统字典 base_material_status
|
||||||
|
*/
|
||||||
|
@TableField("STS")
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@TableField("RMK")
|
@TableField("RMK")
|
||||||
|
|||||||
@@ -44,4 +44,12 @@ public class TemplateInstanceDataDO extends BusinessBaseDO {
|
|||||||
@TableField("FLD_VAL")
|
@TableField("FLD_VAL")
|
||||||
private String fldVal;
|
private String fldVal;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String fldName;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String fldDoc;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
|||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimplePageReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -31,4 +32,8 @@ public interface MaterialInfomationMapper extends BaseMapperX<MaterialInfomation
|
|||||||
.orderByDesc(MaterialInfomationDO::getId));
|
.orderByDesc(MaterialInfomationDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default PageResult<MaterialInfomationDO> selectSimplePage(MaterialInfomationSimplePageReqVO reqVO, LambdaQueryWrapperX<MaterialInfomationDO> wrapper) {
|
||||||
|
return BaseMapperX.super.selectPage(reqVO, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,8 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
|||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimplePageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimpleRespVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
@@ -51,7 +53,7 @@ public interface MaterialInfomationService {
|
|||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 物料信息
|
* @return 物料信息
|
||||||
*/
|
*/
|
||||||
MaterialInfomationDO getMaterialInfomation(Long id);
|
MaterialInfomationRespVO getMaterialInfomation(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得物料信息分页
|
* 获得物料信息分页
|
||||||
@@ -59,7 +61,15 @@ public interface MaterialInfomationService {
|
|||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 物料信息分页
|
* @return 物料信息分页
|
||||||
*/
|
*/
|
||||||
PageResult<MaterialInfomationDO> getMaterialInfomationPage(MaterialInfomationPageReqVO pageReqVO);
|
PageResult<MaterialInfomationRespVO> getMaterialInfomationPage(MaterialInfomationPageReqVO pageReqVO);
|
||||||
|
|
||||||
String getOneTest();
|
String getOneTest();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得精简的物料信息分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页参数
|
||||||
|
* @return 精简分页列表
|
||||||
|
*/
|
||||||
|
PageResult<MaterialInfomationSimpleRespVO> getMaterialInfomationSimplePage(MaterialInfomationSimplePageReqVO pageReqVO);
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,21 @@
|
|||||||
package com.zt.plat.module.base.service.base;
|
package com.zt.plat.module.base.service.base;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimplePageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimpleRespVO;
|
||||||
|
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
||||||
import com.zt.plat.module.base.dal.dao.materialhasclasses.MaterialHasClassesMapper;
|
import com.zt.plat.module.base.dal.dao.materialhasclasses.MaterialHasClassesMapper;
|
||||||
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialhasclasses.MaterialHasClassesDO;
|
import com.zt.plat.module.base.dal.dataobject.materialhasclasses.MaterialHasClassesDO;
|
||||||
import com.zt.plat.module.base.dal.mysql.base.MaterialInfomationMapper;
|
import com.zt.plat.module.base.dal.mysql.base.MaterialInfomationMapper;
|
||||||
import com.zt.plat.module.erp.api.ErpExternalApi;
|
import com.zt.plat.module.erp.api.ErpExternalApi;
|
||||||
@@ -20,12 +26,16 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_CLASSES_LEVEL3_REQUIRED_FOR_MATERIAL;
|
||||||
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_CLASSES_NOT_EXISTS;
|
||||||
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_INFOMATION_NOT_EXISTS;
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_INFOMATION_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,143 +47,254 @@ import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_INFOMATI
|
|||||||
@Validated
|
@Validated
|
||||||
public class MaterialInfomationServiceImpl implements MaterialInfomationService {
|
public class MaterialInfomationServiceImpl implements MaterialInfomationService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialInfomationMapper materialInfomationMapper;
|
private MaterialInfomationMapper materialInfomationMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ErpExternalApi erpExternalApi;
|
private ErpExternalApi erpExternalApi;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialHasClassesMapper materialHasClassesMapper;
|
private MaterialHasClassesMapper materialHasClassesMapper;
|
||||||
|
|
||||||
@Override
|
@Resource
|
||||||
@Transactional(rollbackFor = Exception.class)
|
private MaterialClassesMapper materialClassesMapper;
|
||||||
public MaterialInfomationRespVO createMaterialInfomation(MaterialInfomationSaveReqVO createReqVO) {
|
|
||||||
// 插入
|
|
||||||
MaterialInfomationDO materialInfomation = BeanUtils.toBean(createReqVO, MaterialInfomationDO.class);
|
|
||||||
materialInfomationMapper.insert(materialInfomation);
|
|
||||||
// 维护分类关联
|
|
||||||
if (createReqVO.getClassesId() != null) {
|
|
||||||
MaterialHasClassesDO relation = MaterialHasClassesDO.builder()
|
|
||||||
.classesId(createReqVO.getClassesId())
|
|
||||||
.infomationId(materialInfomation.getId())
|
|
||||||
.build();
|
|
||||||
materialHasClassesMapper.insert(relation);
|
|
||||||
materialInfomation.setClassesId(createReqVO.getClassesId());
|
|
||||||
}
|
|
||||||
// 返回
|
|
||||||
return BeanUtils.toBean(materialInfomation, MaterialInfomationRespVO.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateMaterialInfomation(MaterialInfomationSaveReqVO updateReqVO) {
|
public MaterialInfomationRespVO createMaterialInfomation(MaterialInfomationSaveReqVO createReqVO) {
|
||||||
// 校验存在
|
validateMaterialClassForBinding(createReqVO.getClassesId());
|
||||||
validateMaterialInfomationExists(updateReqVO.getId());
|
MaterialInfomationDO materialInfomation = BeanUtils.toBean(createReqVO, MaterialInfomationDO.class);
|
||||||
// 更新
|
materialInfomationMapper.insert(materialInfomation);
|
||||||
MaterialInfomationDO updateObj = BeanUtils.toBean(updateReqVO, MaterialInfomationDO.class);
|
if (createReqVO.getClassesId() != null) {
|
||||||
materialInfomationMapper.updateById(updateObj);
|
MaterialHasClassesDO relation = MaterialHasClassesDO.builder()
|
||||||
// 更新分类关联
|
.classesId(createReqVO.getClassesId())
|
||||||
materialHasClassesMapper.delete(new LambdaUpdateWrapper<MaterialHasClassesDO>()
|
.infomationId(materialInfomation.getId())
|
||||||
.eq(MaterialHasClassesDO::getInfomationId, updateReqVO.getId()));
|
.build();
|
||||||
if (updateReqVO.getClassesId() != null) {
|
materialHasClassesMapper.insert(relation);
|
||||||
MaterialHasClassesDO relation = MaterialHasClassesDO.builder()
|
materialInfomation.setClassesId(createReqVO.getClassesId());
|
||||||
.classesId(updateReqVO.getClassesId())
|
}
|
||||||
.infomationId(updateReqVO.getId())
|
return CollUtil.getFirst(buildRespList(Collections.singletonList(materialInfomation)));
|
||||||
.build();
|
}
|
||||||
materialHasClassesMapper.insert(relation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialInfomation(Long id) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
// 校验存在
|
public void updateMaterialInfomation(MaterialInfomationSaveReqVO updateReqVO) {
|
||||||
validateMaterialInfomationExists(id);
|
validateMaterialInfomationExists(updateReqVO.getId());
|
||||||
// 删除
|
validateMaterialClassForBinding(updateReqVO.getClassesId());
|
||||||
materialInfomationMapper.deleteById(id);
|
MaterialInfomationDO updateObj = BeanUtils.toBean(updateReqVO, MaterialInfomationDO.class);
|
||||||
materialHasClassesMapper.delete(new LambdaUpdateWrapper<MaterialHasClassesDO>()
|
materialInfomationMapper.updateById(updateObj);
|
||||||
.eq(MaterialHasClassesDO::getInfomationId, id));
|
materialHasClassesMapper.delete(new LambdaUpdateWrapper<MaterialHasClassesDO>()
|
||||||
}
|
.eq(MaterialHasClassesDO::getInfomationId, updateReqVO.getId()));
|
||||||
|
if (updateReqVO.getClassesId() != null) {
|
||||||
|
MaterialHasClassesDO relation = MaterialHasClassesDO.builder()
|
||||||
|
.classesId(updateReqVO.getClassesId())
|
||||||
|
.infomationId(updateReqVO.getId())
|
||||||
|
.build();
|
||||||
|
materialHasClassesMapper.insert(relation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialInfomationListByIds(List<Long> ids) {
|
public void deleteMaterialInfomation(Long id) {
|
||||||
// 校验存在
|
validateMaterialInfomationExists(id);
|
||||||
validateMaterialInfomationExists(ids);
|
materialInfomationMapper.deleteById(id);
|
||||||
// 删除
|
materialHasClassesMapper.delete(new LambdaUpdateWrapper<MaterialHasClassesDO>()
|
||||||
materialInfomationMapper.deleteByIds(ids);
|
.eq(MaterialHasClassesDO::getInfomationId, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMaterialInfomationExists(List<Long> ids) {
|
@Override
|
||||||
List<MaterialInfomationDO> list = materialInfomationMapper.selectByIds(ids);
|
public void deleteMaterialInfomationListByIds(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
validateMaterialInfomationExists(ids);
|
||||||
throw exception(MATERIAL_INFOMATION_NOT_EXISTS);
|
materialInfomationMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void validateMaterialInfomationExists(Long id) {
|
private void validateMaterialInfomationExists(List<Long> ids) {
|
||||||
if (materialInfomationMapper.selectById(id) == null) {
|
List<MaterialInfomationDO> list = materialInfomationMapper.selectByIds(ids);
|
||||||
throw exception(MATERIAL_INFOMATION_NOT_EXISTS);
|
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||||
}
|
throw exception(MATERIAL_INFOMATION_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private void validateMaterialInfomationExists(Long id) {
|
||||||
public MaterialInfomationDO getMaterialInfomation(Long id) {
|
if (materialInfomationMapper.selectById(id) == null) {
|
||||||
MaterialInfomationDO info = materialInfomationMapper.selectById(id);
|
throw exception(MATERIAL_INFOMATION_NOT_EXISTS);
|
||||||
if (info == null) {
|
}
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
MaterialHasClassesDO relation = materialHasClassesMapper.selectFirstOne(MaterialHasClassesDO::getInfomationId, id);
|
|
||||||
if (relation != null) {
|
|
||||||
info.setClassesId(relation.getClassesId());
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private void validateMaterialClassForBinding(Long classesId) {
|
||||||
public PageResult<MaterialInfomationDO> getMaterialInfomationPage(MaterialInfomationPageReqVO pageReqVO) {
|
if (classesId == null) {
|
||||||
List<Long> infomationIds = null;
|
throw exception(MATERIAL_CLASSES_LEVEL3_REQUIRED_FOR_MATERIAL);
|
||||||
List<MaterialHasClassesDO> relationList = Collections.emptyList();
|
}
|
||||||
if (pageReqVO.getClassesId() != null) {
|
MaterialClassesDO materialClasses = materialClassesMapper.selectById(classesId);
|
||||||
relationList = materialHasClassesMapper.selectList(MaterialHasClassesDO::getClassesId, pageReqVO.getClassesId());
|
if (materialClasses == null) {
|
||||||
if (CollUtil.isEmpty(relationList)) {
|
throw exception(MATERIAL_CLASSES_NOT_EXISTS);
|
||||||
return PageResult.empty();
|
}
|
||||||
}
|
if (!isThirdLevelClass(materialClasses)) {
|
||||||
infomationIds = relationList.stream()
|
throw exception(MATERIAL_CLASSES_LEVEL3_REQUIRED_FOR_MATERIAL);
|
||||||
.map(MaterialHasClassesDO::getInfomationId)
|
}
|
||||||
.filter(Objects::nonNull)
|
}
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
PageResult<MaterialInfomationDO> pageResult = materialInfomationMapper.selectPage(pageReqVO, infomationIds);
|
private boolean isThirdLevelClass(MaterialClassesDO materialClasses) {
|
||||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
Long level = materialClasses.getLevel();
|
||||||
return pageResult;
|
if (Objects.equals(level, 3L)) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
if (level != null && level > 3L) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Long depth = resolveClassDepth(materialClasses);
|
||||||
|
return depth != null && depth == 3L;
|
||||||
|
}
|
||||||
|
|
||||||
List<Long> currentInfoIds = pageResult.getList().stream()
|
private Long resolveClassDepth(MaterialClassesDO materialClasses) {
|
||||||
.map(MaterialInfomationDO::getId)
|
long depth = 1L;
|
||||||
.collect(Collectors.toList());
|
Set<Long> visited = new HashSet<>();
|
||||||
|
if (materialClasses.getId() != null) {
|
||||||
|
visited.add(materialClasses.getId());
|
||||||
|
}
|
||||||
|
Long parentId = materialClasses.getParentId();
|
||||||
|
while (parentId != null) {
|
||||||
|
if (!visited.add(parentId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MaterialClassesDO parent = materialClassesMapper.selectById(parentId);
|
||||||
|
if (parent == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
depth++;
|
||||||
|
if (depth > 3L) {
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
parentId = parent.getParentId();
|
||||||
|
}
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
if (pageReqVO.getClassesId() == null) {
|
@Override
|
||||||
relationList = materialHasClassesMapper.selectList(MaterialHasClassesDO::getInfomationId, currentInfoIds);
|
public MaterialInfomationRespVO getMaterialInfomation(Long id) {
|
||||||
}
|
MaterialInfomationDO info = materialInfomationMapper.selectById(id);
|
||||||
|
if (info == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MaterialHasClassesDO relation = materialHasClassesMapper.selectFirstOne(MaterialHasClassesDO::getInfomationId, id);
|
||||||
|
if (relation != null) {
|
||||||
|
info.setClassesId(relation.getClassesId());
|
||||||
|
}
|
||||||
|
return CollUtil.getFirst(buildRespList(Collections.singletonList(info)));
|
||||||
|
}
|
||||||
|
|
||||||
Map<Long, Long> infoClassMap = relationList.stream()
|
@Override
|
||||||
.filter(item -> item.getInfomationId() != null)
|
public PageResult<MaterialInfomationRespVO> getMaterialInfomationPage(MaterialInfomationPageReqVO pageReqVO) {
|
||||||
.collect(Collectors.toMap(MaterialHasClassesDO::getInfomationId, MaterialHasClassesDO::getClassesId, (existing, replacement) -> existing));
|
List<Long> infomationIds = null;
|
||||||
|
List<MaterialHasClassesDO> relationList = Collections.emptyList();
|
||||||
|
if (pageReqVO.getClassesId() != null) {
|
||||||
|
relationList = materialHasClassesMapper.selectList(MaterialHasClassesDO::getClassesId, pageReqVO.getClassesId());
|
||||||
|
if (CollUtil.isEmpty(relationList)) {
|
||||||
|
return PageResult.empty();
|
||||||
|
}
|
||||||
|
infomationIds = relationList.stream()
|
||||||
|
.map(MaterialHasClassesDO::getInfomationId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
pageResult.getList().forEach(item -> item.setClassesId(infoClassMap.get(item.getId())));
|
PageResult<MaterialInfomationDO> pageResult = materialInfomationMapper.selectPage(pageReqVO, infomationIds);
|
||||||
return pageResult;
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
}
|
return PageResult.empty(pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
List<Long> currentInfoIds = pageResult.getList().stream()
|
||||||
public String getOneTest() {
|
.map(MaterialInfomationDO::getId)
|
||||||
ErpProductiveVersionReqDTO reqDTO = new ErpProductiveVersionReqDTO();
|
.collect(Collectors.toList());
|
||||||
reqDTO.setFactoryNumber("5020");
|
|
||||||
reqDTO.setMaterialNumber("224814");
|
|
||||||
CommonResult<String> erpProductiveVersion = erpExternalApi.getErpProductiveVersionByFM(reqDTO);
|
|
||||||
return erpProductiveVersion.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (pageReqVO.getClassesId() == null) {
|
||||||
|
relationList = materialHasClassesMapper.selectList(MaterialHasClassesDO::getInfomationId, currentInfoIds);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
Map<Long, Long> infoClassMap = relationList.stream()
|
||||||
|
.filter(item -> item.getInfomationId() != null)
|
||||||
|
.collect(Collectors.toMap(MaterialHasClassesDO::getInfomationId, MaterialHasClassesDO::getClassesId, (existing, replacement) -> existing));
|
||||||
|
|
||||||
|
pageResult.getList().forEach(item -> item.setClassesId(infoClassMap.get(item.getId())));
|
||||||
|
List<MaterialInfomationRespVO> respList = buildRespList(pageResult.getList());
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOneTest() {
|
||||||
|
ErpProductiveVersionReqDTO reqDTO = new ErpProductiveVersionReqDTO();
|
||||||
|
reqDTO.setFactoryNumber("5020");
|
||||||
|
reqDTO.setMaterialNumber("224814");
|
||||||
|
CommonResult<String> erpProductiveVersion = erpExternalApi.getErpProductiveVersionByFM(reqDTO);
|
||||||
|
return erpProductiveVersion.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<MaterialInfomationSimpleRespVO> getMaterialInfomationSimplePage(MaterialInfomationSimplePageReqVO pageReqVO) {
|
||||||
|
LambdaQueryWrapperX<MaterialInfomationDO> wrapper = new LambdaQueryWrapperX<>();
|
||||||
|
if (StrUtil.isNotBlank(pageReqVO.getKeyword())) {
|
||||||
|
wrapper.and(w -> w.like(MaterialInfomationDO::getCode, pageReqVO.getKeyword())
|
||||||
|
.or().like(MaterialInfomationDO::getName, pageReqVO.getKeyword()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, Long> infoClassMap = Collections.emptyMap();
|
||||||
|
if (pageReqVO.getClassesId() != null) {
|
||||||
|
List<MaterialHasClassesDO> relations = materialHasClassesMapper.selectList(MaterialHasClassesDO::getClassesId, pageReqVO.getClassesId());
|
||||||
|
if (CollUtil.isEmpty(relations)) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), 0L);
|
||||||
|
}
|
||||||
|
List<Long> infoIds = relations.stream()
|
||||||
|
.map(MaterialHasClassesDO::getInfomationId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
if (CollUtil.isEmpty(infoIds)) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), 0L);
|
||||||
|
}
|
||||||
|
wrapper.in(MaterialInfomationDO::getId, infoIds);
|
||||||
|
infoClassMap = relations.stream()
|
||||||
|
.filter(item -> item.getInfomationId() != null)
|
||||||
|
.collect(Collectors.toMap(MaterialHasClassesDO::getInfomationId,
|
||||||
|
MaterialHasClassesDO::getClassesId, (existing, replacement) -> existing));
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.orderByAsc(MaterialInfomationDO::getCode);
|
||||||
|
|
||||||
|
PageResult<MaterialInfomationDO> pageResult = materialInfomationMapper.selectSimplePage(pageReqVO, wrapper);
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageReqVO.getClassesId() == null) {
|
||||||
|
List<Long> infoIds = pageResult.getList().stream().map(MaterialInfomationDO::getId).toList();
|
||||||
|
List<MaterialHasClassesDO> relations = materialHasClassesMapper.selectList(MaterialHasClassesDO::getInfomationId, infoIds);
|
||||||
|
infoClassMap = relations.stream()
|
||||||
|
.filter(item -> item.getInfomationId() != null)
|
||||||
|
.collect(Collectors.toMap(MaterialHasClassesDO::getInfomationId,
|
||||||
|
MaterialHasClassesDO::getClassesId, (existing, replacement) -> existing));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, Long> finalInfoClassMap = infoClassMap;
|
||||||
|
List<MaterialInfomationSimpleRespVO> respList = pageResult.getList().stream().map(item -> {
|
||||||
|
MaterialInfomationSimpleRespVO vo = new MaterialInfomationSimpleRespVO();
|
||||||
|
vo.setId(item.getId());
|
||||||
|
vo.setCode(item.getCode());
|
||||||
|
vo.setName(item.getName());
|
||||||
|
vo.setRemark(item.getRemark());
|
||||||
|
vo.setClassesId(finalInfoClassMap.get(item.getId()));
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MaterialInfomationRespVO> buildRespList(List<MaterialInfomationDO> list) {
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return list.stream()
|
||||||
|
.map(item -> BeanUtils.toBean(item, MaterialInfomationRespVO.class))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -69,4 +69,12 @@ public interface BusinessDictionaryTypeService {
|
|||||||
*/
|
*/
|
||||||
List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByDictionaryTypeId(Long dictionaryTypeId);
|
List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByDictionaryTypeId(Long dictionaryTypeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型编码获取业务字典数据列表
|
||||||
|
*
|
||||||
|
* @param type 字典类型编码
|
||||||
|
* @return 字典数据列表
|
||||||
|
*/
|
||||||
|
List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByType(String type);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.zt.plat.module.base.service.businessdictionarytype;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -116,6 +117,19 @@ public class BusinessDictionaryTypeServiceImpl implements BusinessDictionaryType
|
|||||||
return businessDictionaryDataMapper.selectListByDictionaryTypeId(dictionaryTypeId);
|
return businessDictionaryDataMapper.selectListByDictionaryTypeId(dictionaryTypeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByType(String type) {
|
||||||
|
if (StrUtil.isBlank(type)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
BusinessDictionaryTypeDO dictionaryType = businessDictionaryTypeMapper.selectByType(type);
|
||||||
|
if (dictionaryType == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
// 直接根据类型编码定位字典类型,简化前端查询流程
|
||||||
|
return businessDictionaryDataMapper.selectListByDictionaryTypeId(dictionaryType.getId());
|
||||||
|
}
|
||||||
|
|
||||||
private void createBusinessDictionaryDataList(Long dictionaryTypeId, List<BusinessDictionaryDataDO> list) {
|
private void createBusinessDictionaryDataList(Long dictionaryTypeId, List<BusinessDictionaryDataDO> list) {
|
||||||
list.forEach(o -> o.setDictionaryTypeId(dictionaryTypeId).clean());
|
list.forEach(o -> o.setDictionaryTypeId(dictionaryTypeId).clean());
|
||||||
businessDictionaryDataMapper.insertBatch(list);
|
businessDictionaryDataMapper.insertBatch(list);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public interface DepartmentMaterialService {
|
|||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 组织架构物料
|
* @return 组织架构物料
|
||||||
*/
|
*/
|
||||||
DepartmentMaterialDO getDepartmentMaterial(Long id);
|
DepartmentMaterialRespVO getDepartmentMaterial(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得组织架构物料分页
|
* 获得组织架构物料分页
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import java.util.stream.Collectors;
|
|||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.collection.CollectionUtils;
|
import com.zt.plat.framework.common.util.collection.CollectionUtils;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
||||||
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.*;
|
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.*;
|
||||||
import com.zt.plat.module.base.dal.dao.departmentmaterial.DepartmentMaterialMapper;
|
import com.zt.plat.module.base.dal.dao.departmentmaterial.DepartmentMaterialMapper;
|
||||||
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
||||||
@@ -21,6 +20,9 @@ import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
|||||||
import com.zt.plat.module.base.dal.dataobject.departmentmaterial.DepartmentMaterialDO;
|
import com.zt.plat.module.base.dal.dataobject.departmentmaterial.DepartmentMaterialDO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
||||||
import com.zt.plat.module.base.dal.mysql.base.MaterialInfomationMapper;
|
import com.zt.plat.module.base.dal.mysql.base.MaterialInfomationMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.businessdictionarytype.BusinessDictionaryDataMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.module.system.api.dept.DeptApi;
|
import com.zt.plat.module.system.api.dept.DeptApi;
|
||||||
import com.zt.plat.module.system.api.dept.dto.DeptRespDTO;
|
import com.zt.plat.module.system.api.dept.dto.DeptRespDTO;
|
||||||
|
|
||||||
@@ -45,6 +47,9 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
@Resource
|
@Resource
|
||||||
private MaterialClassesMapper materialClassesMapper;
|
private MaterialClassesMapper materialClassesMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusinessDictionaryDataMapper businessDictionaryDataMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DeptApi deptApi;
|
private DeptApi deptApi;
|
||||||
|
|
||||||
@@ -53,8 +58,8 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
// 插入
|
// 插入
|
||||||
DepartmentMaterialDO departmentMaterial = BeanUtils.toBean(createReqVO, DepartmentMaterialDO.class);
|
DepartmentMaterialDO departmentMaterial = BeanUtils.toBean(createReqVO, DepartmentMaterialDO.class);
|
||||||
departmentMaterialMapper.insert(departmentMaterial);
|
departmentMaterialMapper.insert(departmentMaterial);
|
||||||
// 返回
|
// 构造完整响应,方便前端直接刷新数据
|
||||||
return BeanUtils.toBean(departmentMaterial, DepartmentMaterialRespVO.class);
|
return CollUtil.getFirst(decorateDepartmentMaterials(Collections.singletonList(departmentMaterial)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,8 +101,12 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DepartmentMaterialDO getDepartmentMaterial(Long id) {
|
public DepartmentMaterialRespVO getDepartmentMaterial(Long id) {
|
||||||
return departmentMaterialMapper.selectById(id);
|
DepartmentMaterialDO data = departmentMaterialMapper.selectById(id);
|
||||||
|
if (data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CollUtil.getFirst(decorateDepartmentMaterials(Collections.singletonList(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -124,8 +133,17 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
return PageResult.empty(pageResult.getTotal());
|
return PageResult.empty(pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<DepartmentMaterialRespVO> respList = decorateDepartmentMaterials(pageResult.getList());
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DepartmentMaterialRespVO> decorateDepartmentMaterials(List<DepartmentMaterialDO> sourceList) {
|
||||||
|
if (CollUtil.isEmpty(sourceList)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
// 关联数据准备
|
// 关联数据准备
|
||||||
Set<Long> infoIds = pageResult.getList().stream()
|
Set<Long> infoIds = sourceList.stream()
|
||||||
.map(DepartmentMaterialDO::getInfomationId)
|
.map(DepartmentMaterialDO::getInfomationId)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
@@ -136,7 +154,7 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
.collect(Collectors.toMap(MaterialInfomationDO::getId, Function.identity()));
|
.collect(Collectors.toMap(MaterialInfomationDO::getId, Function.identity()));
|
||||||
|
|
||||||
Set<Long> classIds = new HashSet<>();
|
Set<Long> classIds = new HashSet<>();
|
||||||
pageResult.getList().forEach(item -> {
|
sourceList.forEach(item -> {
|
||||||
if (item.getClassesId() != null) {
|
if (item.getClassesId() != null) {
|
||||||
classIds.add(item.getClassesId());
|
classIds.add(item.getClassesId());
|
||||||
}
|
}
|
||||||
@@ -148,13 +166,13 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
|
|
||||||
Map<Long, MaterialClassesDO> classCache = loadClassHierarchy(classIds);
|
Map<Long, MaterialClassesDO> classCache = loadClassHierarchy(classIds);
|
||||||
|
|
||||||
Set<Long> deptIds = pageResult.getList().stream()
|
Set<Long> deptIds = sourceList.stream()
|
||||||
.map(DepartmentMaterialDO::getDeptId)
|
.map(DepartmentMaterialDO::getDeptId)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
Map<Long, DeptRespDTO> deptMap = Collections.emptyMap();
|
Map<Long, DeptRespDTO> deptMap = Collections.emptyMap();
|
||||||
if (!deptIds.isEmpty()) {
|
if (CollUtil.isNotEmpty(deptIds)) {
|
||||||
try {
|
try {
|
||||||
deptMap = CollectionUtils.convertMap(deptApi.getDeptList(deptIds).getCheckedData(), DeptRespDTO::getId);
|
deptMap = CollectionUtils.convertMap(deptApi.getDeptList(deptIds).getCheckedData(), DeptRespDTO::getId);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
@@ -162,8 +180,18 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DepartmentMaterialRespVO> respList = new ArrayList<>(pageResult.getList().size());
|
Set<String> dictionaryValues = sourceList.stream()
|
||||||
for (DepartmentMaterialDO item : pageResult.getList()) {
|
.map(DepartmentMaterialDO::getDictionaryDataValue)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Map<String, BusinessDictionaryDataDO> dictionaryMap = dictionaryValues.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: businessDictionaryDataMapper.selectListByValues(dictionaryValues).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(BusinessDictionaryDataDO::getValue, Function.identity(), (exist, replace) -> exist));
|
||||||
|
|
||||||
|
List<DepartmentMaterialRespVO> respList = new ArrayList<>(sourceList.size());
|
||||||
|
for (DepartmentMaterialDO item : sourceList) {
|
||||||
DepartmentMaterialRespVO respVO = BeanUtils.toBean(item, DepartmentMaterialRespVO.class);
|
DepartmentMaterialRespVO respVO = BeanUtils.toBean(item, DepartmentMaterialRespVO.class);
|
||||||
|
|
||||||
MaterialInfomationDO info = infoMap.get(item.getInfomationId());
|
MaterialInfomationDO info = infoMap.get(item.getInfomationId());
|
||||||
@@ -195,13 +223,16 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
respVO.setDeptName(deptRespDTO.getName());
|
respVO.setDeptName(deptRespDTO.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
respVO.setStatusLabel(StrUtil.isNotBlank(respVO.getStatusLabel()) ? respVO.getStatusLabel() : "未配置");
|
BusinessDictionaryDataDO dictionaryData = dictionaryMap.get(respVO.getDictionaryDataValue());
|
||||||
|
if (dictionaryData != null) {
|
||||||
|
respVO.setDictionaryDataLabel(dictionaryData.getLabel());
|
||||||
|
} else {
|
||||||
|
respVO.setDictionaryDataLabel(respVO.getDictionaryDataValue());
|
||||||
|
}
|
||||||
|
|
||||||
respVO.setDictionaryDataLabel(respVO.getDictionaryDataValue());
|
|
||||||
respList.add(respVO);
|
respList.add(respVO);
|
||||||
}
|
}
|
||||||
|
return respList;
|
||||||
return new PageResult<>(respList, pageResult.getTotal());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Long, MaterialClassesDO> loadClassHierarchy(Set<Long> initialIds) {
|
private Map<Long, MaterialClassesDO> loadClassHierarchy(Set<Long> initialIds) {
|
||||||
|
|||||||
@@ -10,14 +10,11 @@ import java.util.*;
|
|||||||
import com.zt.plat.module.base.controller.admin.materialclasses.vo.*;
|
import com.zt.plat.module.base.controller.admin.materialclasses.vo.*;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.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.*;
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,10 +29,21 @@ public class MaterialClassesServiceImpl implements MaterialClassesService {
|
|||||||
@Resource
|
@Resource
|
||||||
private MaterialClassesMapper materialClassesMapper;
|
private MaterialClassesMapper materialClassesMapper;
|
||||||
|
|
||||||
|
private static final int MAX_LEVEL = 3;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialClassesRespVO createMaterialClasses(MaterialClassesSaveReqVO createReqVO) {
|
public MaterialClassesRespVO createMaterialClasses(MaterialClassesSaveReqVO createReqVO) {
|
||||||
|
Long normalizedParentId = normalizeParentId(createReqVO.getParentId());
|
||||||
|
MaterialClassesDO parent = validateAndGetParent(null, normalizedParentId);
|
||||||
|
long resolvedLevel = resolveLevel(parent);
|
||||||
|
validateLevel(resolvedLevel);
|
||||||
|
if (createReqVO.getLevel() != null && !Objects.equals(createReqVO.getLevel(), resolvedLevel)) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
// 插入
|
// 插入
|
||||||
MaterialClassesDO materialClasses = BeanUtils.toBean(createReqVO, MaterialClassesDO.class);
|
MaterialClassesDO materialClasses = BeanUtils.toBean(createReqVO, MaterialClassesDO.class);
|
||||||
|
materialClasses.setParentId(normalizedParentId);
|
||||||
|
materialClasses.setLevel(resolvedLevel);
|
||||||
materialClassesMapper.insert(materialClasses);
|
materialClassesMapper.insert(materialClasses);
|
||||||
// 返回
|
// 返回
|
||||||
return BeanUtils.toBean(materialClasses, MaterialClassesRespVO.class);
|
return BeanUtils.toBean(materialClasses, MaterialClassesRespVO.class);
|
||||||
@@ -45,8 +53,18 @@ public class MaterialClassesServiceImpl implements MaterialClassesService {
|
|||||||
public void updateMaterialClasses(MaterialClassesSaveReqVO updateReqVO) {
|
public void updateMaterialClasses(MaterialClassesSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateMaterialClassesExists(updateReqVO.getId());
|
validateMaterialClassesExists(updateReqVO.getId());
|
||||||
|
Long normalizedParentId = normalizeParentId(updateReqVO.getParentId());
|
||||||
|
MaterialClassesDO parent = validateAndGetParent(updateReqVO.getId(), normalizedParentId);
|
||||||
|
long resolvedLevel = resolveLevel(parent);
|
||||||
|
validateLevel(resolvedLevel);
|
||||||
|
if (updateReqVO.getLevel() != null && !Objects.equals(updateReqVO.getLevel(), resolvedLevel)) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
ensureChildrenCompatible(updateReqVO.getId(), resolvedLevel);
|
||||||
// 更新
|
// 更新
|
||||||
MaterialClassesDO updateObj = BeanUtils.toBean(updateReqVO, MaterialClassesDO.class);
|
MaterialClassesDO updateObj = BeanUtils.toBean(updateReqVO, MaterialClassesDO.class);
|
||||||
|
updateObj.setParentId(normalizedParentId);
|
||||||
|
updateObj.setLevel(resolvedLevel);
|
||||||
materialClassesMapper.updateById(updateObj);
|
materialClassesMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,4 +112,80 @@ public class MaterialClassesServiceImpl implements MaterialClassesService {
|
|||||||
return materialClassesMapper.selectList();
|
return materialClassesMapper.selectList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Long normalizeParentId(Long parentId) {
|
||||||
|
if (parentId == null || parentId <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MaterialClassesDO validateAndGetParent(Long currentId, Long parentId) {
|
||||||
|
if (parentId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (currentId != null && Objects.equals(currentId, parentId)) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
MaterialClassesDO parent = materialClassesMapper.selectById(parentId);
|
||||||
|
if (parent == null) {
|
||||||
|
throw exception(MATERIAL_CLASSES_PARENT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
if (parent.getLevel() == null) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
if (parent.getLevel() >= MAX_LEVEL) {
|
||||||
|
throw exception(MATERIAL_CLASSES_MAX_LEVEL_EXCEEDED);
|
||||||
|
}
|
||||||
|
if (currentId != null) {
|
||||||
|
Long cursorId = parent.getParentId();
|
||||||
|
while (cursorId != null && cursorId > 0) {
|
||||||
|
if (Objects.equals(cursorId, currentId)) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
MaterialClassesDO cursor = materialClassesMapper.selectById(cursorId);
|
||||||
|
if (cursor == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cursorId = cursor.getParentId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long resolveLevel(MaterialClassesDO parent) {
|
||||||
|
if (parent == null) {
|
||||||
|
return 1L;
|
||||||
|
}
|
||||||
|
Long parentLevel = parent.getLevel();
|
||||||
|
if (parentLevel == null) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
return parentLevel + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateLevel(long level) {
|
||||||
|
if (level < 1L) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
if (level > MAX_LEVEL) {
|
||||||
|
throw exception(MATERIAL_CLASSES_MAX_LEVEL_EXCEEDED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureChildrenCompatible(Long currentId, long level) {
|
||||||
|
List<MaterialClassesDO> children = materialClassesMapper.selectList(MaterialClassesDO::getParentId, currentId);
|
||||||
|
if (CollUtil.isEmpty(children)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long expectedChildLevel = level + 1;
|
||||||
|
if (expectedChildLevel > MAX_LEVEL) {
|
||||||
|
throw exception(MATERIAL_CLASSES_LEVEL_CONFLICT_WITH_CHILDREN);
|
||||||
|
}
|
||||||
|
boolean mismatch = children.stream()
|
||||||
|
.anyMatch(child -> child.getLevel() == null || !Objects.equals(child.getLevel(), expectedChildLevel));
|
||||||
|
if (mismatch) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,12 @@ package com.zt.plat.module.base.service.materialproperties;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import jakarta.validation.*;
|
import jakarta.validation.*;
|
||||||
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesPageReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesRespVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSaveReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSimplePageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSimpleRespVO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料属性 Service 接口
|
* 物料属性 Service 接口
|
||||||
@@ -49,7 +51,7 @@ public interface MaterialPropertiesService {
|
|||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 物料属性
|
* @return 物料属性
|
||||||
*/
|
*/
|
||||||
MaterialPropertiesDO getMaterialProperties(Long id);
|
MaterialPropertiesRespVO getMaterialProperties(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得物料属性分页
|
* 获得物料属性分页
|
||||||
@@ -57,6 +59,14 @@ public interface MaterialPropertiesService {
|
|||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 物料属性分页
|
* @return 物料属性分页
|
||||||
*/
|
*/
|
||||||
PageResult<MaterialPropertiesDO> getMaterialPropertiesPage(MaterialPropertiesPageReqVO pageReqVO);
|
PageResult<MaterialPropertiesRespVO> getMaterialPropertiesPage(MaterialPropertiesPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得精简的物料属性分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 精简分页结果
|
||||||
|
*/
|
||||||
|
PageResult<MaterialPropertiesSimpleRespVO> getMaterialPropertiesSimplePage(MaterialPropertiesSimplePageReqVO pageReqVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,43 @@
|
|||||||
package com.zt.plat.module.base.service.materialproperties;
|
package com.zt.plat.module.base.service.materialproperties;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesPageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesRespVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSaveReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSimplePageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSimpleRespVO;
|
||||||
import com.zt.plat.module.base.dal.dao.materialproperties.MaterialPropertiesMapper;
|
import com.zt.plat.module.base.dal.dao.materialproperties.MaterialPropertiesMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.quantityUnitRelation.QuantityUnitRelationMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.unitQuantity.UnitQuantityMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.untInfo.UntInfoMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.businessdictionarytype.BusinessDictionaryDataMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.unitQuantity.UnitQuantityDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.untInfo.UntInfoDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_PROPERTIES_NOT_EXISTS;
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.diffList;
|
|
||||||
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料属性 Service 实现类
|
* 物料属性 Service 实现类
|
||||||
*
|
|
||||||
* @author 后台管理-1
|
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
@@ -32,39 +46,43 @@ public class MaterialPropertiesServiceImpl implements MaterialPropertiesService
|
|||||||
@Resource
|
@Resource
|
||||||
private MaterialPropertiesMapper materialPropertiesMapper;
|
private MaterialPropertiesMapper materialPropertiesMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private QuantityUnitRelationMapper quantityUnitRelationMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UnitQuantityMapper unitQuantityMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UntInfoMapper untInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusinessDictionaryDataMapper businessDictionaryDataMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialPropertiesRespVO createMaterialProperties(MaterialPropertiesSaveReqVO createReqVO) {
|
public MaterialPropertiesRespVO createMaterialProperties(MaterialPropertiesSaveReqVO createReqVO) {
|
||||||
// 插入
|
|
||||||
MaterialPropertiesDO materialProperties = BeanUtils.toBean(createReqVO, MaterialPropertiesDO.class);
|
MaterialPropertiesDO materialProperties = BeanUtils.toBean(createReqVO, MaterialPropertiesDO.class);
|
||||||
materialPropertiesMapper.insert(materialProperties);
|
materialPropertiesMapper.insert(materialProperties);
|
||||||
// 返回
|
return CollUtil.getFirst(buildRespList(Collections.singletonList(materialProperties)));
|
||||||
return BeanUtils.toBean(materialProperties, MaterialPropertiesRespVO.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMaterialProperties(MaterialPropertiesSaveReqVO updateReqVO) {
|
public void updateMaterialProperties(MaterialPropertiesSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
|
||||||
validateMaterialPropertiesExists(updateReqVO.getId());
|
validateMaterialPropertiesExists(updateReqVO.getId());
|
||||||
// 更新
|
|
||||||
MaterialPropertiesDO updateObj = BeanUtils.toBean(updateReqVO, MaterialPropertiesDO.class);
|
MaterialPropertiesDO updateObj = BeanUtils.toBean(updateReqVO, MaterialPropertiesDO.class);
|
||||||
materialPropertiesMapper.updateById(updateObj);
|
materialPropertiesMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialProperties(Long id) {
|
public void deleteMaterialProperties(Long id) {
|
||||||
// 校验存在
|
|
||||||
validateMaterialPropertiesExists(id);
|
validateMaterialPropertiesExists(id);
|
||||||
// 删除
|
|
||||||
materialPropertiesMapper.deleteById(id);
|
materialPropertiesMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialPropertiesListByIds(List<Long> ids) {
|
public void deleteMaterialPropertiesListByIds(List<Long> ids) {
|
||||||
// 校验存在
|
|
||||||
validateMaterialPropertiesExists(ids);
|
validateMaterialPropertiesExists(ids);
|
||||||
// 删除
|
|
||||||
materialPropertiesMapper.deleteByIds(ids);
|
materialPropertiesMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMaterialPropertiesExists(List<Long> ids) {
|
private void validateMaterialPropertiesExists(List<Long> ids) {
|
||||||
List<MaterialPropertiesDO> list = materialPropertiesMapper.selectByIds(ids);
|
List<MaterialPropertiesDO> list = materialPropertiesMapper.selectByIds(ids);
|
||||||
@@ -80,13 +98,122 @@ public class MaterialPropertiesServiceImpl implements MaterialPropertiesService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialPropertiesDO getMaterialProperties(Long id) {
|
public MaterialPropertiesRespVO getMaterialProperties(Long id) {
|
||||||
return materialPropertiesMapper.selectById(id);
|
MaterialPropertiesDO entity = materialPropertiesMapper.selectById(id);
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CollUtil.getFirst(buildRespList(Collections.singletonList(entity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<MaterialPropertiesDO> getMaterialPropertiesPage(MaterialPropertiesPageReqVO pageReqVO) {
|
public PageResult<MaterialPropertiesRespVO> getMaterialPropertiesPage(MaterialPropertiesPageReqVO pageReqVO) {
|
||||||
return materialPropertiesMapper.selectPage(pageReqVO);
|
PageResult<MaterialPropertiesDO> pageResult = materialPropertiesMapper.selectPage(pageReqVO);
|
||||||
|
List<MaterialPropertiesRespVO> respList = buildRespList(pageResult.getList());
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<MaterialPropertiesSimpleRespVO> getMaterialPropertiesSimplePage(MaterialPropertiesSimplePageReqVO pageReqVO) {
|
||||||
|
PageResult<MaterialPropertiesDO> pageResult = materialPropertiesMapper.selectSimplePage(pageReqVO);
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), pageResult.getTotal());
|
||||||
|
}
|
||||||
|
List<MaterialPropertiesRespVO> respList = buildRespList(pageResult.getList());
|
||||||
|
List<MaterialPropertiesSimpleRespVO> simpleList = buildSimpleList(respList);
|
||||||
|
return new PageResult<>(simpleList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MaterialPropertiesSimpleRespVO> buildSimpleList(List<MaterialPropertiesRespVO> respList) {
|
||||||
|
if (CollUtil.isEmpty(respList)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return respList.stream().map(item -> {
|
||||||
|
MaterialPropertiesSimpleRespVO vo = new MaterialPropertiesSimpleRespVO();
|
||||||
|
vo.setId(item.getId());
|
||||||
|
vo.setCode(item.getCode());
|
||||||
|
vo.setName(item.getName());
|
||||||
|
vo.setDataType(item.getDataType());
|
||||||
|
vo.setUnitName(item.getUnitName());
|
||||||
|
vo.setUnitSymbol(item.getUnitSymbol());
|
||||||
|
vo.setDictionaryDataValue(item.getDictionaryDataValue());
|
||||||
|
vo.setDictionaryDataLabel(item.getDictionaryDataLabel());
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MaterialPropertiesRespVO> buildRespList(List<MaterialPropertiesDO> list) {
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> relationIds = list.stream()
|
||||||
|
.map(MaterialPropertiesDO::getUnitQuantityId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<Long, QuantityUnitRelationDO> relationMap = relationIds.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: quantityUnitRelationMapper.selectBatchIds(relationIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(QuantityUnitRelationDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
Set<Long> quantityIds = relationMap.values().stream()
|
||||||
|
.map(QuantityUnitRelationDO::getUntQtyId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Set<Long> unitIds = relationMap.values().stream()
|
||||||
|
.map(QuantityUnitRelationDO::getUntId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<Long, UnitQuantityDO> quantityMap = quantityIds.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: unitQuantityMapper.selectBatchIds(quantityIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(UnitQuantityDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
Map<Long, UntInfoDO> unitMap = unitIds.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: untInfoMapper.selectBatchIds(unitIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(UntInfoDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
Set<String> dictionaryValues = list.stream()
|
||||||
|
.map(MaterialPropertiesDO::getDictionaryDataValue)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<String, BusinessDictionaryDataDO> dictionaryMap = dictionaryValues.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: businessDictionaryDataMapper.selectListByValues(dictionaryValues).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(BusinessDictionaryDataDO::getValue, Function.identity(), (existing, replacement) -> existing));
|
||||||
|
|
||||||
|
return list.stream().map(item -> {
|
||||||
|
MaterialPropertiesRespVO respVO = BeanUtils.toBean(item, MaterialPropertiesRespVO.class);
|
||||||
|
|
||||||
|
QuantityUnitRelationDO relation = relationMap.get(item.getUnitQuantityId());
|
||||||
|
if (relation != null) {
|
||||||
|
UnitQuantityDO quantity = quantityMap.get(relation.getUntQtyId());
|
||||||
|
if (quantity != null) {
|
||||||
|
respVO.setUnitQuantityName(quantity.getName());
|
||||||
|
}
|
||||||
|
UntInfoDO unit = unitMap.get(relation.getUntId());
|
||||||
|
if (unit != null) {
|
||||||
|
respVO.setUnitName(unit.getName());
|
||||||
|
respVO.setUnitSymbol(unit.getSmb());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BusinessDictionaryDataDO dictionaryDataDO = dictionaryMap.get(item.getDictionaryDataValue());
|
||||||
|
if (dictionaryDataDO != null) {
|
||||||
|
respVO.setDictionaryDataLabel(dictionaryDataDO.getLabel());
|
||||||
|
} else {
|
||||||
|
respVO.setDictionaryDataLabel(respVO.getDictionaryDataValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return respVO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import jakarta.validation.*;
|
|||||||
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.*;
|
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.*;
|
||||||
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
|
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.QuantityUnitRelationSimplePageReqVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计量单位量与单位关联 Service 接口
|
* 计量单位量与单位关联 Service 接口
|
||||||
@@ -85,4 +86,12 @@ public interface QuantityUnitRelationService {
|
|||||||
*/
|
*/
|
||||||
void deleteUnitWithRelation(@Valid DeleteUnitWithRelationReqVO deleteReqVO);
|
void deleteUnitWithRelation(@Valid DeleteUnitWithRelationReqVO deleteReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询精简的量纲-单位关联分页,用于下拉框
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询条件
|
||||||
|
* @return 关联关系列表
|
||||||
|
*/
|
||||||
|
PageResult<QuantityUnitRelationSimpleRespVO> getQuantityUnitRelationSimplePage(QuantityUnitRelationSimplePageReqVO pageReqVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.zt.plat.module.base.service.quantityUnitRelation;
|
package com.zt.plat.module.base.service.quantityUnitRelation;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -11,11 +12,19 @@ import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.*;
|
|||||||
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
|
||||||
import com.zt.plat.module.base.dal.dao.quantityUnitRelation.QuantityUnitRelationMapper;
|
import com.zt.plat.module.base.dal.dao.quantityUnitRelation.QuantityUnitRelationMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.unitQuantity.UnitQuantityMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.untInfo.UntInfoMapper;
|
||||||
import com.zt.plat.module.base.service.untInfo.UntInfoService;
|
import com.zt.plat.module.base.service.untInfo.UntInfoService;
|
||||||
import com.zt.plat.module.base.controller.admin.untInfo.vo.UntInfoSaveReqVO;
|
import com.zt.plat.module.base.controller.admin.untInfo.vo.UntInfoSaveReqVO;
|
||||||
import com.zt.plat.module.base.controller.admin.untInfo.vo.UntInfoRespVO;
|
import com.zt.plat.module.base.controller.admin.untInfo.vo.UntInfoRespVO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.unitQuantity.UnitQuantityDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.untInfo.UntInfoDO;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
@@ -36,6 +45,12 @@ public class QuantityUnitRelationServiceImpl implements QuantityUnitRelationServ
|
|||||||
@Resource
|
@Resource
|
||||||
private UntInfoService untInfoService;
|
private UntInfoService untInfoService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UnitQuantityMapper unitQuantityMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UntInfoMapper untInfoMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QuantityUnitRelationRespVO createQuantityUnitRelation(QuantityUnitRelationSaveReqVO createReqVO) {
|
public QuantityUnitRelationRespVO createQuantityUnitRelation(QuantityUnitRelationSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@@ -170,4 +185,90 @@ public class QuantityUnitRelationServiceImpl implements QuantityUnitRelationServ
|
|||||||
untInfoService.deleteUntInfo(deleteReqVO.getUntId());
|
untInfoService.deleteUntInfo(deleteReqVO.getUntId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<QuantityUnitRelationSimpleRespVO> getQuantityUnitRelationSimplePage(QuantityUnitRelationSimplePageReqVO pageReqVO) {
|
||||||
|
LambdaQueryWrapperX<QuantityUnitRelationDO> wrapper = new LambdaQueryWrapperX<>();
|
||||||
|
wrapper.eqIfPresent(QuantityUnitRelationDO::getUntQtyId, pageReqVO.getUntQtyId());
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(pageReqVO.getKeyword())) {
|
||||||
|
String keyword = pageReqVO.getKeyword();
|
||||||
|
List<Long> matchedQtyIds = unitQuantityMapper.selectList(new LambdaQueryWrapperX<UnitQuantityDO>()
|
||||||
|
.like(UnitQuantityDO::getName, keyword))
|
||||||
|
.stream()
|
||||||
|
.map(UnitQuantityDO::getId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
List<Long> matchedUntIds = untInfoMapper.selectList(new LambdaQueryWrapperX<UntInfoDO>()
|
||||||
|
.like(UntInfoDO::getName, keyword)
|
||||||
|
.or()
|
||||||
|
.like(UntInfoDO::getSmb, keyword))
|
||||||
|
.stream()
|
||||||
|
.map(UntInfoDO::getId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(matchedQtyIds) && CollUtil.isEmpty(matchedUntIds)) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.and(w -> {
|
||||||
|
boolean hasCondition = false;
|
||||||
|
if (CollUtil.isNotEmpty(matchedQtyIds)) {
|
||||||
|
w.in(QuantityUnitRelationDO::getUntQtyId, matchedQtyIds);
|
||||||
|
hasCondition = true;
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(matchedUntIds)) {
|
||||||
|
if (hasCondition) {
|
||||||
|
w.or();
|
||||||
|
}
|
||||||
|
w.in(QuantityUnitRelationDO::getUntId, matchedUntIds);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.orderByAsc(QuantityUnitRelationDO::getUntQtyId).orderByAsc(QuantityUnitRelationDO::getId);
|
||||||
|
|
||||||
|
PageResult<QuantityUnitRelationDO> pageResult = quantityUnitRelationMapper.selectSimplePage(pageReqVO, wrapper);
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> qtyIds = pageResult.getList().stream()
|
||||||
|
.map(QuantityUnitRelationDO::getUntQtyId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Set<Long> unitIds = pageResult.getList().stream()
|
||||||
|
.map(QuantityUnitRelationDO::getUntId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<Long, UnitQuantityDO> qtyMap = qtyIds.isEmpty() ? Collections.emptyMap()
|
||||||
|
: unitQuantityMapper.selectBatchIds(qtyIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(UnitQuantityDO::getId, Function.identity()));
|
||||||
|
Map<Long, UntInfoDO> unitMap = unitIds.isEmpty() ? Collections.emptyMap()
|
||||||
|
: untInfoMapper.selectBatchIds(unitIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(UntInfoDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
List<QuantityUnitRelationSimpleRespVO> respList = pageResult.getList().stream().map(item -> {
|
||||||
|
QuantityUnitRelationSimpleRespVO vo = new QuantityUnitRelationSimpleRespVO();
|
||||||
|
vo.setId(item.getId());
|
||||||
|
vo.setUntQtyId(item.getUntQtyId());
|
||||||
|
UnitQuantityDO quantityDO = qtyMap.get(item.getUntQtyId());
|
||||||
|
if (quantityDO != null) {
|
||||||
|
vo.setUntQtyName(quantityDO.getName());
|
||||||
|
}
|
||||||
|
vo.setUntId(item.getUntId());
|
||||||
|
UntInfoDO untInfoDO = unitMap.get(item.getUntId());
|
||||||
|
if (untInfoDO != null) {
|
||||||
|
vo.setUntName(untInfoDO.getName());
|
||||||
|
vo.setUntSymbol(untInfoDO.getSmb());
|
||||||
|
}
|
||||||
|
vo.setIsBse(item.getIsBse());
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ public class TemplateInstanceItemServiceImpl implements TemplateInstanceItemServ
|
|||||||
@Override
|
@Override
|
||||||
public void updateTemplateInstanceItem(TemplateInstanceItemSaveReqVO updateReqVO) {
|
public void updateTemplateInstanceItem(TemplateInstanceItemSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateTemplateInstanceItemExists(updateReqVO.getInscId());
|
validateTemplateInstanceItemExists(updateReqVO.getId());
|
||||||
// 更新
|
// 更新
|
||||||
TemplateInstanceItemDO updateObj = BeanUtils.toBean(updateReqVO, TemplateInstanceItemDO.class);
|
TemplateInstanceItemDO updateObj = BeanUtils.toBean(updateReqVO, TemplateInstanceItemDO.class);
|
||||||
templateInstanceItemMapper.updateById(updateObj);
|
templateInstanceItemMapper.updateById(updateObj);
|
||||||
|
|||||||
@@ -217,18 +217,18 @@ public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
|||||||
// 校验当前状态是否能够进行发布
|
// 校验当前状态是否能够进行发布
|
||||||
publishReqVOS.forEach(reqVO -> {
|
publishReqVOS.forEach(reqVO -> {
|
||||||
TemplateInstanceDO templateInstanceDO = templateInstanceMapper.selectById(reqVO.getId());
|
TemplateInstanceDO templateInstanceDO = templateInstanceMapper.selectById(reqVO.getId());
|
||||||
if (templateInstanceDO.getCntt()==null||templateInstanceDO.getCntt().isEmpty()){
|
if (templateInstanceDO.getCntt() == null || templateInstanceDO.getCntt().isEmpty()) {
|
||||||
throw exception(TEMPLATE_INSTANCE_FILE_NOT_EXISTS);
|
throw exception(TEMPLATE_INSTANCE_FILE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
String currentStatus = reqVO.getCurrentStatus();
|
String currentStatus = reqVO.getCurrentStatus();
|
||||||
if (currentStatus.isEmpty()) {
|
if (currentStatus.isEmpty()) {
|
||||||
currentStatus =templateInstanceDO.getSts();
|
currentStatus = templateInstanceDO.getSts();
|
||||||
}
|
}
|
||||||
PublishStatusEnum status = PublishStatusEnum.fromCode(currentStatus);
|
PublishStatusEnum status = PublishStatusEnum.fromCode(currentStatus);
|
||||||
boolean transitionAllowed = false;
|
boolean transitionAllowed = false;
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
transitionAllowed = status.isTransitionAllowed(TmplStsEnum.DRAFT.getCode());
|
transitionAllowed = status.isTransitionAllowed(TmplStsEnum.DRAFT.getCode());
|
||||||
if (!transitionAllowed){
|
if (!transitionAllowed) {
|
||||||
transitionAllowed = status.isTransitionAllowed(TmplStsEnum.START.getCode());
|
transitionAllowed = status.isTransitionAllowed(TmplStsEnum.START.getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
|||||||
newTpInstanceDO.setTenantId(templateInstanceDO.getTenantId());
|
newTpInstanceDO.setTenantId(templateInstanceDO.getTenantId());
|
||||||
newTpInstanceDO.setVer(incrementVersion(templateInstanceDO.getVer()));
|
newTpInstanceDO.setVer(incrementVersion(templateInstanceDO.getVer()));
|
||||||
newTpInstanceDO.setPublishTime(LocalDateTime.now());
|
newTpInstanceDO.setPublishTime(LocalDateTime.now());
|
||||||
newTpInstanceDO.setOrigCntt(templateInstanceDO.getCntt()!=null?templateInstanceDO.getCntt():templateInstanceDO.getOrigCntt());//模板实例内容,默认为上一个版本的当前文件内容
|
newTpInstanceDO.setOrigCntt(templateInstanceDO.getCntt() != null ? templateInstanceDO.getCntt() : templateInstanceDO.getOrigCntt());//模板实例内容,默认为上一个版本的当前文件内容
|
||||||
newTpInstanceDO.setCreateTime(null);
|
newTpInstanceDO.setCreateTime(null);
|
||||||
newTpInstanceDO.setUpdateTime(null);
|
newTpInstanceDO.setUpdateTime(null);
|
||||||
templateInstanceMapper.insert(newTpInstanceDO);
|
templateInstanceMapper.insert(newTpInstanceDO);
|
||||||
@@ -409,9 +409,19 @@ public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
|||||||
|
|
||||||
// 实例数据
|
// 实例数据
|
||||||
private List<TemplateInstanceDataRespVO> setTemplateInstanceDataRespVOS(Long id) {
|
private List<TemplateInstanceDataRespVO> setTemplateInstanceDataRespVOS(Long id) {
|
||||||
return BeanUtils.toBean(templateInstanceDataMapper.selectList(new LambdaQueryWrapper<TemplateInstanceDataDO>()
|
List<TemplateInstanceDataRespVO> templateInstanceDataRespVOS = BeanUtils.toBean(templateInstanceDataMapper.selectList(new LambdaQueryWrapper<TemplateInstanceDataDO>()
|
||||||
.eq(TemplateInstanceDataDO::getInscId, id)
|
.eq(TemplateInstanceDataDO::getInscId, id)
|
||||||
.eq(TemplateInstanceDataDO::getCompanyId, CompanyContextHolder.getCompanyId())), TemplateInstanceDataRespVO.class);
|
.eq(TemplateInstanceDataDO::getCompanyId, CompanyContextHolder.getCompanyId())), TemplateInstanceDataRespVO.class);
|
||||||
|
List<TmplTpFldDO> tmplTpListByValKeys = tmplTpFldService.getTmplTpListByValKeys(templateInstanceDataRespVOS.stream().map(TemplateInstanceDataRespVO::getFldKy).toList());
|
||||||
|
templateInstanceDataRespVOS.forEach(templateInstanceDataRespVO -> {
|
||||||
|
tmplTpListByValKeys.forEach(tmplTpFldDO -> {
|
||||||
|
if (templateInstanceDataRespVO.getFldKy().equals(tmplTpFldDO.getFldKy())) {
|
||||||
|
templateInstanceDataRespVO.setFldName(tmplTpFldDO.getFldName());
|
||||||
|
templateInstanceDataRespVO.setFldDoc(tmplTpFldDO.getFldDoc());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return templateInstanceDataRespVOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateStatusCanDelete(List<Long> ids) {
|
private void validateStatusCanDelete(List<Long> ids) {
|
||||||
@@ -470,11 +480,11 @@ public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
|||||||
List<String> itmIds = templateInstanceItemMapper.selectList(new LambdaQueryWrapper<TemplateInstanceItemDO>().eq(TemplateInstanceItemDO::getInscId, id)).stream().map(TemplateInstanceItemDO::getItmId).toList();
|
List<String> itmIds = templateInstanceItemMapper.selectList(new LambdaQueryWrapper<TemplateInstanceItemDO>().eq(TemplateInstanceItemDO::getInscId, id)).stream().map(TemplateInstanceItemDO::getItmId).toList();
|
||||||
|
|
||||||
// 例模版条款去条款库查询条款信息
|
// 例模版条款去条款库查询条款信息
|
||||||
if (!itmIds.isEmpty()){
|
if (!itmIds.isEmpty()) {
|
||||||
List<TmplItmRespVO> tmplItmRespVOS = BeanUtils.toBean(tmplItmService.listTmplItmByIds(itmIds), TmplItmRespVO.class);
|
List<TmplItmRespVO> tmplItmRespVOS = BeanUtils.toBean(tmplItmService.listTmplItmByIds(itmIds), TmplItmRespVO.class);
|
||||||
fieldAndClauseRespVO.setTmplItmRespVOS(BeanUtils.toBean(tmplItmRespVOS, TmplItmRespVO.class));
|
fieldAndClauseRespVO.setTmplItmRespVOS(BeanUtils.toBean(tmplItmRespVOS, TmplItmRespVO.class));
|
||||||
}
|
}
|
||||||
if (!valKeys.isEmpty()){
|
if (!valKeys.isEmpty()) {
|
||||||
//例模版字段去字段库查询字段信息
|
//例模版字段去字段库查询字段信息
|
||||||
List<TmplTpFldDO> tmplTpListByValKeys = tmplTpFldService.getTmplTpListByValKeys(valKeys);
|
List<TmplTpFldDO> tmplTpListByValKeys = tmplTpFldService.getTmplTpListByValKeys(valKeys);
|
||||||
fieldAndClauseRespVO.setTmplFldRespVOS(BeanUtils.toBean(tmplTpListByValKeys, TmplFldRespVO.class));
|
fieldAndClauseRespVO.setTmplFldRespVOS(BeanUtils.toBean(tmplTpListByValKeys, TmplFldRespVO.class));
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ public class TmplTpFldServiceImpl extends ServiceImpl<TmplTpFldMapper, TmplTpFld
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TmplTpFldDO> getTmplTpListByValKeys(List<String> valNames) {
|
public List<TmplTpFldDO> getTmplTpListByValKeys(List<String> valNames) {
|
||||||
|
if (CollUtil.isEmpty(valNames)){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
return baseMapper.selectList(new LambdaQueryWrapper<TmplTpFldDO>().in(TmplTpFldDO::getFldKy, valNames));
|
return baseMapper.selectList(new LambdaQueryWrapper<TmplTpFldDO>().in(TmplTpFldDO::getFldKy, valNames));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ package com.zt.plat.module.contractorder.api;
|
|||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.module.contractorder.api.dto.contract.ContractRespDTO;
|
import com.zt.plat.module.contractorder.api.dto.contract.ContractRespDTO;
|
||||||
|
import com.zt.plat.module.contractorder.api.dto.order.PrchOrdDtlDTO;
|
||||||
import com.zt.plat.module.contractorder.api.dto.order.PurchaseOrderWithDetailsDTO;
|
import com.zt.plat.module.contractorder.api.dto.order.PurchaseOrderWithDetailsDTO;
|
||||||
|
import com.zt.plat.module.contractorder.api.dto.order.SalesOrdDtlDTO;
|
||||||
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContract;
|
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContract;
|
||||||
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContractPageReq;
|
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContractPageReq;
|
||||||
import com.zt.plat.module.contractorder.enums.ApiConstants;
|
import com.zt.plat.module.contractorder.enums.ApiConstants;
|
||||||
@@ -47,4 +49,22 @@ public interface ContractApi {
|
|||||||
@GetMapping(PREFIX + "/logistics/list/page")
|
@GetMapping(PREFIX + "/logistics/list/page")
|
||||||
@Operation(summary = "国贸2.0系统合同分页查询")
|
@Operation(summary = "国贸2.0系统合同分页查询")
|
||||||
CommonResult<PageResult<IntContract>> logisticsListPage(IntContractPageReq pageReq);
|
CommonResult<PageResult<IntContract>> logisticsListPage(IntContractPageReq pageReq);
|
||||||
|
|
||||||
|
@GetMapping(PREFIX + "/sales-order-detail-by-id")
|
||||||
|
@Operation(summary = "通过消费订单详情id获取消费订单详情")
|
||||||
|
CommonResult<SalesOrdDtlDTO> getSalesOrderDetailById(@RequestParam("id") Long id);
|
||||||
|
|
||||||
|
@GetMapping(PREFIX + "/sales-order-detail-by-ids")
|
||||||
|
@Operation(summary = "通过消费订单详情id批量获取消费订单详情")
|
||||||
|
CommonResult<List<SalesOrdDtlDTO>> getSalesOrderDetailByIds(@RequestParam("ids") List<Long> ids);
|
||||||
|
|
||||||
|
@GetMapping(PREFIX + "/po-order-detail-by-id")
|
||||||
|
@Operation(summary = "通过采购订单详情id获取消费订单详情")
|
||||||
|
CommonResult<PrchOrdDtlDTO> getPoOrderDetailById(@RequestParam("id") Long id);
|
||||||
|
|
||||||
|
@GetMapping(PREFIX + "/po-order-detail-by-ids")
|
||||||
|
@Operation(summary = "通过采购订单详情id批量获取消费订单详情")
|
||||||
|
CommonResult<List<PrchOrdDtlDTO>> getPoOrderDetailByIds(@RequestParam("ids") List<Long> ids);
|
||||||
|
|
||||||
|
//销售采购融合。主子表
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.zt.plat.module.contractorder.api;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.module.contractorder.api.dto.order.OrderDTO;
|
||||||
|
import com.zt.plat.module.contractorder.enums.ApiConstants;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@FeignClient(name = ApiConstants.NAME)
|
||||||
|
@Tag(name = "RPC 服务 - 订单")
|
||||||
|
public interface OrderApi {
|
||||||
|
String PREFIX = ApiConstants.PREFIX + "/order";
|
||||||
|
@PostMapping(PREFIX + "/order-by-order-ids")
|
||||||
|
@Operation(summary = "通过订单id获取订单信息", description = "通过订单编号获取订单信息")
|
||||||
|
CommonResult<List<OrderDTO>> getOrderByOrderIds(@RequestBody List<Long> ids);
|
||||||
|
|
||||||
|
@PostMapping(PREFIX + "/order-by-order-nos")
|
||||||
|
@Operation(summary = "通过订单号批量获取订单信息", description = "通过订单编号获取订单信息")
|
||||||
|
CommonResult<List<OrderDTO>> getOrderByOrderNos(@RequestBody List<String> orderNoS);
|
||||||
|
}
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
package com.zt.plat.module.contractorder.api.dto.order;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrdDtlDTO {
|
||||||
|
|
||||||
|
// ========================== 公共属性(两个类均存在,统一保留)==========================
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单主键(PrchOrdDtlDTO.ordId / SalesOrdDtlDTO.orderId 统一命名) Y
|
||||||
|
*/
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行项目;推送ERP(必须)(PrchOrdDtlDTO.lineNum / SalesOrdDtlDTO.lineNumber 统一命名)Y
|
||||||
|
*/
|
||||||
|
private Long lineNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料名称(PrchOrdDtlDTO.mtrlName / SalesOrdDtlDTO.materialName 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String mtrlName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编码;推送ERP(必须)(PrchOrdDtlDTO.mtrlNum / SalesOrdDtlDTO.materialNumber 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String mtrlNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工厂名称(PrchOrdDtlDTO.rcvFactName / SalesOrdDtlDTO.factoryName 统一命名) Y
|
||||||
|
*/
|
||||||
|
private String factoryName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工厂编码;推送ERP(必须)(PrchOrdDtlDTO.rcvFactNum / SalesOrdDtlDTO.factoryNumber 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String factoryNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库位名称(PrchOrdDtlDTO.rcvWrhName / SalesOrdDtlDTO.warehouseName 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String warehouseName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库位编码;推送ERP(PrchOrdDtlDTO.rcvWrhNum / SalesOrdDtlDTO.warehouseNumber 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String warehouseNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计量单位;推送ERP(必须)(PrchOrdDtlDTO.unt / SalesOrdDtlDTO.unit 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂估数量;推送ERP(必须)(PrchOrdDtlDTO.qty / SalesOrdDtlDTO.quantity 统一命名,类型统一为BigDecimal)Y
|
||||||
|
*/
|
||||||
|
private BigDecimal quantity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目类别;推送ERP(PrchOrdDtlDTO.prjCtgr / SalesOrdDtlDTO.projectCategory 统一命名)
|
||||||
|
*/
|
||||||
|
private String projectCategory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小协议号(PrchOrdDtlDTO.agrNum / SalesOrdDtlDTO.agreementNumber 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String agreementNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 金属元素缩写(PrchOrdDtlDTO.elemAbbr / SalesOrdDtlDTO.elementAbbreviation 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String elementAbbreviation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 金属元素名称(PrchOrdDtlDTO.elemName / SalesOrdDtlDTO.elementName 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String elementName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 金属元素编码(PrchOrdDtlDTO.elemCdg / SalesOrdDtlDTO.elementNumber 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String elementCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用(字典:ERP_CTRT_YN);处理明细中多个相同物料,只能允许一种物料启用(PrchOrdDtlDTO.isEnb / SalesOrdDtlDTO.isEnable 统一命名)Y
|
||||||
|
*/
|
||||||
|
private String isEnable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税码(字典: PRCH_TAX);推送ERP Y
|
||||||
|
*/
|
||||||
|
private String taxNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税率 Y
|
||||||
|
*/
|
||||||
|
private BigDecimal taxRte;
|
||||||
|
|
||||||
|
// ========================== 采购订单特有属性(PrchOrdDtlDTO 独有)==========================
|
||||||
|
/**
|
||||||
|
* 含税单价;推送ERP(必须)
|
||||||
|
*/
|
||||||
|
private BigDecimal inTaxUprc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格单位;推送ERP
|
||||||
|
*/
|
||||||
|
private BigDecimal prcUnt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否基于GR的发票校验;推送ERP
|
||||||
|
*/
|
||||||
|
private String isGrInv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否允许无限制收货;推送ERP
|
||||||
|
*/
|
||||||
|
private String isUnlRcv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次;推送ERP
|
||||||
|
*/
|
||||||
|
private String bat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 科目分配类别(字典: PRCH_ACTS_CTGR);推送ERP:联动订单类型,固定资产订单A,服务订单S-销售服务费K-成本中心F-订单
|
||||||
|
*/
|
||||||
|
private String actsCtgr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料组编码(字典: PRCH_MATERIAL_GROUP);推送ERP:联动订单类型,服务订单必传 Y
|
||||||
|
*/
|
||||||
|
private String mtrlCpntNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料组描述;推送ERP:联动订单类型,服务订单必传 Y
|
||||||
|
*/
|
||||||
|
private String mtrlCpntDsp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短文本 Y
|
||||||
|
*/
|
||||||
|
private String shrtTxt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退货标识X标识退货;推送ERP
|
||||||
|
*/
|
||||||
|
private String isRlbkCgo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否免费收货标识X;推送ERP
|
||||||
|
*/
|
||||||
|
private String isFreeRcv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 外部行项目号;推送ERP
|
||||||
|
*/
|
||||||
|
private Long outLineNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注信息-需求单位;推送ERP
|
||||||
|
*/
|
||||||
|
private String rmkUnt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注信息-物料详细;推送ERP
|
||||||
|
*/
|
||||||
|
private String rmkMtrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交货起始日期;推送ERP Y
|
||||||
|
*/
|
||||||
|
private LocalDateTime bgnDt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交货截止日期;推送ERP Y
|
||||||
|
*/
|
||||||
|
private LocalDateTime ddlDt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已收货量
|
||||||
|
*/
|
||||||
|
private BigDecimal lstQty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已移库量库;存针对该订单产生的移库量
|
||||||
|
*/
|
||||||
|
private BigDecimal trfQty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移库工厂名称 Y
|
||||||
|
*/
|
||||||
|
private String trfFactName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移库工厂编码 Y
|
||||||
|
*/
|
||||||
|
private String trfFactNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移库库位名称 Y
|
||||||
|
*/
|
||||||
|
private String trfWrhName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移库库位编码 Y
|
||||||
|
*/
|
||||||
|
private String trfWrhNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注 Y
|
||||||
|
*/
|
||||||
|
private String rmk;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 原料湿重;推送ERP
|
||||||
|
*/
|
||||||
|
private BigDecimal origWet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 销售物料号;推送ERP:科目分配类别为S时必填
|
||||||
|
*/
|
||||||
|
private String saleMtrlNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计型内部订单;推送ERP
|
||||||
|
*/
|
||||||
|
private String inOrd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购类别;推送ERP:0-生产性物资类1-项目投资类
|
||||||
|
*/
|
||||||
|
private String prchCtgr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 科目分配详情;科目分配类别为K或P时使用(JSON)
|
||||||
|
*/
|
||||||
|
private String actsCtgrDtl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 委托加工详情;委托加工订单使用(JSON)
|
||||||
|
*/
|
||||||
|
private String enttDtl;
|
||||||
|
|
||||||
|
// ========================== 销售订单特有属性(SalesOrdDtlDTO 独有)==========================
|
||||||
|
/**
|
||||||
|
* 开票类型;推送ERP(必须)
|
||||||
|
*/
|
||||||
|
private String invoiceType;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 稅分类(字典:SALE_TAX);推送ERP(必须)
|
||||||
|
// */
|
||||||
|
// private String taxAcctasscat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装运地点;推送ERP
|
||||||
|
*/
|
||||||
|
private String shippingPlace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料科目分配组;推送ERP(必须)
|
||||||
|
*/
|
||||||
|
private String metalAcctasscatGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总价
|
||||||
|
*/
|
||||||
|
private BigDecimal gross;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格条件详情;推送ERP(必须):JSON
|
||||||
|
*/
|
||||||
|
private String priceConditionDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来料加工原料详情;推送ERP:订单类型(JSON)
|
||||||
|
*/
|
||||||
|
private String originDetail;
|
||||||
|
}
|
||||||
@@ -0,0 +1,291 @@
|
|||||||
|
package com.zt.plat.module.contractorder.api.dto.order;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* ERP订单号
|
||||||
|
*/
|
||||||
|
@TableField("ORD_SAP_NUM")
|
||||||
|
private String orderSAPNumber;
|
||||||
|
/**
|
||||||
|
* 订单号
|
||||||
|
*/
|
||||||
|
@TableField("SYS_ORD_NUM")
|
||||||
|
private String systemOrderNumber;
|
||||||
|
/**
|
||||||
|
* 公司名称
|
||||||
|
*/
|
||||||
|
@TableField("CPN_NAME")
|
||||||
|
private String cpName;
|
||||||
|
/**
|
||||||
|
* 公司编码;推送ERP(必须)
|
||||||
|
*/
|
||||||
|
@TableField("CPN_NUM")
|
||||||
|
private String cpNum;
|
||||||
|
/**
|
||||||
|
* 客商编码;推送ERP(必须)
|
||||||
|
*/
|
||||||
|
@TableField("SPLR_NUM")
|
||||||
|
private String supplierNumber;
|
||||||
|
/**
|
||||||
|
* 客商名称
|
||||||
|
*/
|
||||||
|
@TableField("SPLR_NAME")
|
||||||
|
private String supplierName;
|
||||||
|
/**
|
||||||
|
* 订单类型(字典:PRCH_ORD_TP);推送ERP(必须)
|
||||||
|
*/
|
||||||
|
@TableField("TP")
|
||||||
|
private String type;
|
||||||
|
/**
|
||||||
|
* 凭证日期;推送ERP(必须)
|
||||||
|
*/
|
||||||
|
@TableField("VCHR_DT")
|
||||||
|
private LocalDateTime voucherDate;
|
||||||
|
/**
|
||||||
|
* 采购组织编码;推送ERP(必须)
|
||||||
|
*/
|
||||||
|
@TableField("PRCH_ORGZ_CD")
|
||||||
|
private String purchaseOrganizationCustomsDeclaration;
|
||||||
|
/**
|
||||||
|
* 收货工厂名称
|
||||||
|
*/
|
||||||
|
@TableField("RCV_FACT_NAME")
|
||||||
|
private String receiveFactoryName;
|
||||||
|
/**
|
||||||
|
* 收货工厂编码;推送ERP(必须)
|
||||||
|
*/
|
||||||
|
@TableField("RCV_FACT_NUM")
|
||||||
|
private String receiveFactoryNumber;
|
||||||
|
/**
|
||||||
|
* 收货库位名称
|
||||||
|
*/
|
||||||
|
@TableField("RCV_WRH_NAME")
|
||||||
|
private String receiveWarehouseName;
|
||||||
|
/**
|
||||||
|
* 收货库位编码;推送ERP
|
||||||
|
*/
|
||||||
|
@TableField("RCV_WRH_NUM")
|
||||||
|
private String receiveWarehouseNumber;
|
||||||
|
/**
|
||||||
|
* 采购组编码(字典:PRCH_GRP_TP);推送ERP(必须)
|
||||||
|
*/
|
||||||
|
@TableField("PRCH_GRP")
|
||||||
|
private String purchaseGroup;
|
||||||
|
/**
|
||||||
|
* 货币码(字典:CUR);推送ERP(必须)
|
||||||
|
*/
|
||||||
|
@TableField("CUR_NUM")
|
||||||
|
private String currencyNumber;
|
||||||
|
/**
|
||||||
|
* 汇率;推送ERP
|
||||||
|
*/
|
||||||
|
@TableField("EXCH_RTE")
|
||||||
|
private BigDecimal exchangeRate;
|
||||||
|
/**
|
||||||
|
* 合同纸质合同号;推送ERP(必须)
|
||||||
|
*/
|
||||||
|
@TableField("PPR_CTRT_NUM")
|
||||||
|
private String paperContractNumber;
|
||||||
|
/**
|
||||||
|
* 小协议号;推送ERP
|
||||||
|
*/
|
||||||
|
@TableField("AGR_NUM")
|
||||||
|
private String agreementNumber;
|
||||||
|
/**
|
||||||
|
* 备注;推送ERP
|
||||||
|
*/
|
||||||
|
@TableField("RMK")
|
||||||
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 代理方编码;推送ERP
|
||||||
|
*/
|
||||||
|
@TableField("AGT_NUM")
|
||||||
|
private String agentNumber;
|
||||||
|
/**
|
||||||
|
* 代理方名称
|
||||||
|
*/
|
||||||
|
@TableField("AGT_NAME")
|
||||||
|
private String agentName;
|
||||||
|
/**
|
||||||
|
* 系统合同编号
|
||||||
|
*/
|
||||||
|
@TableField("CTRT_NUM")
|
||||||
|
private String contractNumber;
|
||||||
|
/**
|
||||||
|
* 物料编码
|
||||||
|
*/
|
||||||
|
@TableField("MTRL_NUM")
|
||||||
|
private String materialNumber;
|
||||||
|
/**
|
||||||
|
* 物料名称
|
||||||
|
*/
|
||||||
|
@TableField("MTRL_NAME")
|
||||||
|
private String materialName;
|
||||||
|
/**
|
||||||
|
* 合同名称
|
||||||
|
*/
|
||||||
|
@TableField("CTRT_NAME")
|
||||||
|
private String contractName;
|
||||||
|
/**
|
||||||
|
* 小户头号
|
||||||
|
*/
|
||||||
|
@TableField("TNT_NUM")
|
||||||
|
private String tenantNumber;
|
||||||
|
/**
|
||||||
|
* ERP公司编号
|
||||||
|
*/
|
||||||
|
@TableField("ERP_PRCH_CPN_NUM")
|
||||||
|
private String erpPurchaseCompanyNumber;
|
||||||
|
/**
|
||||||
|
* ERP公司名称
|
||||||
|
*/
|
||||||
|
@TableField("ERP_PRCH_CPN_NAME")
|
||||||
|
private String erpPurchaseCompanyName;
|
||||||
|
/**
|
||||||
|
* ERP客商公司编码
|
||||||
|
*/
|
||||||
|
@TableField("ERP_SALE_CPN_NUM")
|
||||||
|
private String erpSalesCompanyNumber;
|
||||||
|
/**
|
||||||
|
* ERP客商公司名称
|
||||||
|
*/
|
||||||
|
@TableField("ERP_SALE_CPN_NAME")
|
||||||
|
private String erpSalesCompanyName;
|
||||||
|
/**
|
||||||
|
* 采购组织名称
|
||||||
|
*/
|
||||||
|
@TableField("PRCH_ORGZ_NAME")
|
||||||
|
private String purchaseOrganizationName;
|
||||||
|
/**
|
||||||
|
* ERP状态(字典: ERP_REQ_STS)
|
||||||
|
*/
|
||||||
|
@TableField("ERP_STS")
|
||||||
|
private String erpStatus;
|
||||||
|
/**
|
||||||
|
* 请求ERP失败原因
|
||||||
|
*/
|
||||||
|
@TableField("CAUS")
|
||||||
|
private String cause;
|
||||||
|
/**
|
||||||
|
* 订单状态(字典:PRCH_ORD_STS)
|
||||||
|
*/
|
||||||
|
@TableField("STS")
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 采购组名称
|
||||||
|
*/
|
||||||
|
@TableField("PRCH_GRP_NAME")
|
||||||
|
private String purchaseGroupName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程实例编号
|
||||||
|
*/
|
||||||
|
@TableField("PRCS_INSC_ID")
|
||||||
|
private String processInstanceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程当前任务节点id
|
||||||
|
*/
|
||||||
|
@TableField("TSK_NDE_ID")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批意见
|
||||||
|
*/
|
||||||
|
@TableField("RVW_ONN")
|
||||||
|
private String reviewOpinion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否需要审批
|
||||||
|
*/
|
||||||
|
@TableField("IS_PUSH")
|
||||||
|
private int isPush;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计量单位
|
||||||
|
*/
|
||||||
|
@TableField("UNT")
|
||||||
|
private String unt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料字典
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableField("MTRL_TP")
|
||||||
|
private String mtrlTp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单分类
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableField("SPLY_BSN_TP")
|
||||||
|
private String splyBsnTp;
|
||||||
|
/**
|
||||||
|
* 产品组编码
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableField("PDT_GRP_CDG")
|
||||||
|
private String pdtGrpCdg;
|
||||||
|
/**
|
||||||
|
* 产品组名
|
||||||
|
*/
|
||||||
|
@TableField("PDT_GRP_NAME")
|
||||||
|
private String pdtGrpName;
|
||||||
|
/**
|
||||||
|
* 分销聚道编码
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableField("SALE_ACS_CDG")
|
||||||
|
private String saleAcsCdg;
|
||||||
|
/**
|
||||||
|
* 分销聚道名称
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableField("SALE_ACS_NAME")
|
||||||
|
private String saleAcsName;
|
||||||
|
/**
|
||||||
|
* 销售组织编码
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableField("SALE_ORGZ_CD")
|
||||||
|
private String saleOrgzCd;
|
||||||
|
/**
|
||||||
|
* 销售组织名称
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableField("SALE_ORGZ_NAME")
|
||||||
|
private String saleOrgzName;
|
||||||
|
/**
|
||||||
|
* 付款方名称
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableField("PYER_NAME")
|
||||||
|
private String payerName;
|
||||||
|
/**
|
||||||
|
* 付款方编码
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableField("PYER_NUM")
|
||||||
|
private String payerNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单明细
|
||||||
|
*/
|
||||||
|
private List<OrdDtlDTO> OrdDtlDTOS;
|
||||||
|
}
|
||||||
@@ -109,6 +109,11 @@ public class PurchaseOrderWithDetailsDTO {
|
|||||||
* 物料编码
|
* 物料编码
|
||||||
*/
|
*/
|
||||||
private String materialNumber;
|
private String materialNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位
|
||||||
|
*/
|
||||||
|
private String unt;
|
||||||
/**
|
/**
|
||||||
* 物料名称
|
* 物料名称
|
||||||
*/
|
*/
|
||||||
@@ -189,6 +194,10 @@ public class PurchaseOrderWithDetailsDTO {
|
|||||||
* 订单类型
|
* 订单类型
|
||||||
*/
|
*/
|
||||||
private String splyBsnTp;
|
private String splyBsnTp;
|
||||||
|
/**
|
||||||
|
* 税码
|
||||||
|
*/
|
||||||
|
private String taxNum;
|
||||||
/**
|
/**
|
||||||
* 采购订单明细
|
* 采购订单明细
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.zt.plat.module.contractorder.api.vo.contract;
|
package com.zt.plat.module.contractorder.api.vo.contract;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 查询参数降级规则列表 Request VO")
|
@Schema(description = "管理后台 - 查询参数降级规则列表 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class DemotesQueryReqVO {
|
public class DemotesQueryReqVO extends PageParam {
|
||||||
|
|
||||||
@Schema(description = "合同名称")
|
@Schema(description = "合同名称")
|
||||||
private String contractName;
|
private String contractName;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.zt.plat.module.contractorder.api.vo.contract;
|
package com.zt.plat.module.contractorder.api.vo.contract;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 查询结算公式列表 Request VO")
|
@Schema(description = "管理后台 - 查询结算公式列表 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class FormulasQueryReqVO {
|
public class FormulasQueryReqVO extends PageParam {
|
||||||
|
|
||||||
@Schema(description = "合同名称")
|
@Schema(description = "合同名称")
|
||||||
private String contractName;
|
private String contractName;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.zt.plat.module.contractorder.api.vo.contract;
|
package com.zt.plat.module.contractorder.api.vo.contract;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 查询不计价规则列表 Request VO")
|
@Schema(description = "管理后台 - 查询不计价规则列表 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class NotsQueryReqVO {
|
public class NotsQueryReqVO extends PageParam {
|
||||||
|
|
||||||
@Schema(description = "合同名称")
|
@Schema(description = "合同名称")
|
||||||
private String contractName;
|
private String contractName;
|
||||||
|
|||||||
@@ -6,8 +6,24 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class IntContractPageReq extends PageParam {
|
public class IntContractPageReq extends PageParam {
|
||||||
@Schema(description = "合同编号")
|
|
||||||
private String contractCode;
|
// 合同名称:模糊搜索
|
||||||
@Schema(description = "合同名称")
|
@Schema(description = "合同名称")
|
||||||
private String contractName;
|
private String contractName;
|
||||||
|
// 合同有效期起:日期选择
|
||||||
|
@Schema(description = "合同有效期起")
|
||||||
|
private String contractStartDate;
|
||||||
|
// 合同有效期止:日期选择
|
||||||
|
@Schema(description = "合同有效期止")
|
||||||
|
private String contractEndDate;
|
||||||
|
// 合同版本号:精确搜索 TODO 不确定
|
||||||
|
// 签约地:模糊搜索
|
||||||
|
@Schema(description = "签约地")
|
||||||
|
private String signSite;
|
||||||
|
// 经办人姓名:模糊搜索
|
||||||
|
@Schema(description = "经办人姓名")
|
||||||
|
private String createdUserName;
|
||||||
|
// 签约日期: 模糊搜索
|
||||||
|
@Schema(description = "签约日期")
|
||||||
|
private String signDate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractMainDO;
|
|||||||
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractOtherFieldDO;
|
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractOtherFieldDO;
|
||||||
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractOtherFormDO;
|
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractOtherFormDO;
|
||||||
import com.zt.plat.module.contractorder.dal.dataobject.contract.SystemRelativityDO;
|
import com.zt.plat.module.contractorder.dal.dataobject.contract.SystemRelativityDO;
|
||||||
|
import com.zt.plat.module.contractorder.dal.dataobject.purchaseorder.PrchOrdDtlDO;
|
||||||
import com.zt.plat.module.contractorder.dal.dataobject.purchaseorder.PurchaseOrderDO;
|
import com.zt.plat.module.contractorder.dal.dataobject.purchaseorder.PurchaseOrderDO;
|
||||||
import com.zt.plat.module.contractorder.dal.dataobject.salesorder.SalesOrderDO;
|
import com.zt.plat.module.contractorder.dal.dataobject.salesorder.SalesOrderDO;
|
||||||
import com.zt.plat.module.contractorder.dal.dataobject.salesorder.SalesOrderDetailDO;
|
import com.zt.plat.module.contractorder.dal.dataobject.salesorder.SalesOrderDetailDO;
|
||||||
@@ -26,6 +27,7 @@ import com.zt.plat.module.contractorder.dal.mysql.contract.ContractMainMapper;
|
|||||||
import com.zt.plat.module.contractorder.dal.mysql.contract.ContractOtherFieldMapper;
|
import com.zt.plat.module.contractorder.dal.mysql.contract.ContractOtherFieldMapper;
|
||||||
import com.zt.plat.module.contractorder.dal.mysql.contract.ContractOtherFormMapper;
|
import com.zt.plat.module.contractorder.dal.mysql.contract.ContractOtherFormMapper;
|
||||||
import com.zt.plat.module.contractorder.dal.mysql.contract.SystemRelativityMapper;
|
import com.zt.plat.module.contractorder.dal.mysql.contract.SystemRelativityMapper;
|
||||||
|
import com.zt.plat.module.contractorder.dal.mysql.purchaseorder.PrchOrdDtlMapper;
|
||||||
import com.zt.plat.module.contractorder.dal.mysql.salesorder.SalesOrderDetailMapper;
|
import com.zt.plat.module.contractorder.dal.mysql.salesorder.SalesOrderDetailMapper;
|
||||||
import com.zt.plat.module.contractorder.dal.mysql.salesorder.SalesOrderMapper;
|
import com.zt.plat.module.contractorder.dal.mysql.salesorder.SalesOrderMapper;
|
||||||
import com.zt.plat.module.contractorder.enums.contract.DictEnum;
|
import com.zt.plat.module.contractorder.enums.contract.DictEnum;
|
||||||
@@ -42,7 +44,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -250,6 +254,12 @@ public class ContractApiImpl implements ContractApi {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国贸合同信息未映射合同主信息字段保存到动态条款
|
||||||
|
*
|
||||||
|
* @param reqVO 国贸合同信息
|
||||||
|
* @param contractId 合同主信息ID
|
||||||
|
*/
|
||||||
private void saveIntContractFields(IntContract reqVO, Long contractId) {
|
private void saveIntContractFields(IntContract reqVO, Long contractId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -370,10 +380,28 @@ public class ContractApiImpl implements ContractApi {
|
|||||||
DictEnum.SPLY_BSN_TP_03BX.getCode()
|
DictEnum.SPLY_BSN_TP_03BX.getCode()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
// 合同编号
|
// 合同名称:模糊搜索
|
||||||
queryWrapperX.likeIfPresent(ContractMainDO::getContractPaperNumber, pageReq.getContractCode());
|
|
||||||
// 合同名称
|
|
||||||
queryWrapperX.likeIfPresent(ContractMainDO::getContractName, pageReq.getContractName());
|
queryWrapperX.likeIfPresent(ContractMainDO::getContractName, pageReq.getContractName());
|
||||||
|
// 合同有效期起:日期选择
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
queryWrapperX.geIfPresent(ContractMainDO::getStartDate,
|
||||||
|
pageReq.getContractStartDate() != null
|
||||||
|
? LocalDateTime.of(LocalDate.parse(pageReq.getContractStartDate(), formatter), LocalTime.MIN)
|
||||||
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
||||||
|
: null);
|
||||||
|
// 合同有效期止:日期选择
|
||||||
|
queryWrapperX.leIfPresent(ContractMainDO::getEndDate,
|
||||||
|
pageReq.getContractEndDate() != null
|
||||||
|
? LocalDateTime.of(LocalDate.parse(pageReq.getContractEndDate(), formatter), LocalTime.MAX)
|
||||||
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
||||||
|
: null);
|
||||||
|
// 签约地:模糊搜索
|
||||||
|
queryWrapperX.likeIfPresent(ContractMainDO::getSignPlace, pageReq.getSignSite());
|
||||||
|
// 经办人姓名:模糊搜索
|
||||||
|
// 签约日期: 模糊搜索
|
||||||
|
if (pageReq.getSignDate() != null) {
|
||||||
|
queryWrapperX.apply("to_char(SGN_DT, 'yyyymmdd') like concat('%',{0},'%')", pageReq.getSignDate());
|
||||||
|
}
|
||||||
|
|
||||||
// 查询
|
// 查询
|
||||||
PageResult<ContractMainDO> pageResult = contractMainMapper.selectPage(pageReq, queryWrapperX);
|
PageResult<ContractMainDO> pageResult = contractMainMapper.selectPage(pageReq, queryWrapperX);
|
||||||
@@ -387,63 +415,66 @@ public class ContractApiImpl implements ContractApi {
|
|||||||
|
|
||||||
// 遍历查询结果,设置返回数据列表
|
// 遍历查询结果,设置返回数据列表
|
||||||
if (pageResult.getTotal() > 0) {
|
if (pageResult.getTotal() > 0) {
|
||||||
pageResult.getList().forEach(contractMainDO -> {
|
pageResult.getList().forEach(contractMainDO
|
||||||
|
-> resultList.add(getIntContractByMainId(contractMainDO.getId())));
|
||||||
// 合同ID
|
|
||||||
Long mainDOId = contractMainDO.getId();
|
|
||||||
|
|
||||||
// 合同动态条款查询
|
|
||||||
List<ContractOtherFormDO> otherFormDOs = contractOtherFormMapper.selectList(
|
|
||||||
new LambdaQueryWrapperX<ContractOtherFormDO>()
|
|
||||||
.eq(ContractOtherFormDO::getContractMainId, mainDOId)
|
|
||||||
);
|
|
||||||
// 合同动态条款明细查询
|
|
||||||
List<ContractOtherFieldDO> otherFieldDOs = contractOtherFieldMapper.selectList(
|
|
||||||
new LambdaQueryWrapperX<ContractOtherFieldDO>()
|
|
||||||
.eq(ContractOtherFieldDO::getContractMainId, mainDOId)
|
|
||||||
);
|
|
||||||
|
|
||||||
JSONObject resultJson = new JSONObject();
|
|
||||||
|
|
||||||
// 设置主信息
|
|
||||||
otherFieldDOs.stream()
|
|
||||||
.filter(otherFieldDO -> otherFieldDO.getRelativityId() == null)
|
|
||||||
.forEach(otherFieldDO
|
|
||||||
-> resultJson.putOnce(otherFieldDO.getFieldNumber(), otherFieldDO.getFieldValue()));
|
|
||||||
|
|
||||||
// 设置明细信息
|
|
||||||
otherFormDOs.stream()
|
|
||||||
.collect(Collectors.groupingBy(ContractOtherFormDO::getFormNumber))
|
|
||||||
.forEach((key, value) -> {
|
|
||||||
JSONArray detailsJson = new JSONArray();
|
|
||||||
value.forEach(detail -> {
|
|
||||||
// 根据条款id筛选条款明细
|
|
||||||
Stream<ContractOtherFieldDO> stream = otherFieldDOs.stream()
|
|
||||||
.filter(otherFieldDO
|
|
||||||
-> Objects.equals(otherFieldDO.getRelativityId(), detail.getId()));
|
|
||||||
if ("attachList".equals(key)) {
|
|
||||||
// 基础数据类型
|
|
||||||
stream.forEach(otherFieldDO
|
|
||||||
-> detailsJson.add(otherFieldDO.getFieldValue()));
|
|
||||||
} else {
|
|
||||||
// 对象数据类型
|
|
||||||
JSONObject detailJson = new JSONObject();
|
|
||||||
stream.forEach(otherFieldDO
|
|
||||||
-> detailJson.putOnce(otherFieldDO.getFieldNumber(), otherFieldDO.getFieldValue()));
|
|
||||||
detailsJson.add(detailJson);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
resultJson.putOnce(key, detailsJson);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 添加到结果集
|
|
||||||
resultList.add(resultJson.toBean(IntContract.class));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return success(result);
|
return success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取国贸合同信息通过合同主信息ID
|
||||||
|
*
|
||||||
|
* @param mainId 同主信息ID
|
||||||
|
* @return 国贸合同信息
|
||||||
|
*/
|
||||||
|
private IntContract getIntContractByMainId(Long mainId) {
|
||||||
|
// 合同动态条款查询
|
||||||
|
List<ContractOtherFormDO> otherFormDOs = contractOtherFormMapper.selectList(
|
||||||
|
new LambdaQueryWrapperX<ContractOtherFormDO>()
|
||||||
|
.eq(ContractOtherFormDO::getContractMainId, mainId)
|
||||||
|
);
|
||||||
|
// 合同动态条款明细查询
|
||||||
|
List<ContractOtherFieldDO> otherFieldDOs = contractOtherFieldMapper.selectList(
|
||||||
|
new LambdaQueryWrapperX<ContractOtherFieldDO>()
|
||||||
|
.eq(ContractOtherFieldDO::getContractMainId, mainId)
|
||||||
|
);
|
||||||
|
|
||||||
|
JSONObject resultJson = new JSONObject();
|
||||||
|
|
||||||
|
// 设置主信息
|
||||||
|
otherFieldDOs.stream()
|
||||||
|
.filter(otherFieldDO -> otherFieldDO.getRelativityId() == null)
|
||||||
|
.forEach(otherFieldDO
|
||||||
|
-> resultJson.putOnce(otherFieldDO.getFieldNumber(), otherFieldDO.getFieldValue()));
|
||||||
|
|
||||||
|
// 设置明细信息
|
||||||
|
otherFormDOs.stream()
|
||||||
|
.collect(Collectors.groupingBy(ContractOtherFormDO::getFormNumber))
|
||||||
|
.forEach((key, value) -> {
|
||||||
|
JSONArray detailsJson = new JSONArray();
|
||||||
|
value.forEach(detail -> {
|
||||||
|
// 根据条款id筛选条款明细
|
||||||
|
Stream<ContractOtherFieldDO> stream = otherFieldDOs.stream()
|
||||||
|
.filter(otherFieldDO
|
||||||
|
-> Objects.equals(otherFieldDO.getRelativityId(), detail.getId()));
|
||||||
|
if ("attachList".equals(key)) {
|
||||||
|
// 基础数据类型
|
||||||
|
stream.forEach(otherFieldDO
|
||||||
|
-> detailsJson.add(otherFieldDO.getFieldValue()));
|
||||||
|
} else {
|
||||||
|
// 对象数据类型
|
||||||
|
JSONObject detailJson = new JSONObject();
|
||||||
|
stream.forEach(otherFieldDO
|
||||||
|
-> detailJson.putOnce(otherFieldDO.getFieldNumber(), otherFieldDO.getFieldValue()));
|
||||||
|
detailsJson.add(detailJson);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
resultJson.putOnce(key, detailsJson);
|
||||||
|
});
|
||||||
|
return resultJson.toBean(IntContract.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<List<PurchaseOrderWithDetailsDTO>> getOrderByOrderIds(List<Long> ids) {
|
public CommonResult<List<PurchaseOrderWithDetailsDTO>> getOrderByOrderIds(List<Long> ids) {
|
||||||
if (ids == null || ids.isEmpty()) {
|
if (ids == null || ids.isEmpty()) {
|
||||||
@@ -475,6 +506,12 @@ public class ContractApiImpl implements ContractApi {
|
|||||||
return CommonResult.success(purchaseOrderDetails);
|
return CommonResult.success(purchaseOrderDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国贸合同信息映射到合同主信息
|
||||||
|
*
|
||||||
|
* @param reqVO 国贸合同信息
|
||||||
|
* @return 合同主信息
|
||||||
|
*/
|
||||||
private ContractMainDO internationalToMainDO(IntContract reqVO) {
|
private ContractMainDO internationalToMainDO(IntContract reqVO) {
|
||||||
|
|
||||||
// 合同主信息表映射
|
// 合同主信息表映射
|
||||||
@@ -592,4 +629,28 @@ public class ContractApiImpl implements ContractApi {
|
|||||||
});
|
});
|
||||||
return purchaseOrderWithDetailsDTOS;
|
return purchaseOrderWithDetailsDTOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<SalesOrdDtlDTO> getSalesOrderDetailById(Long id) {
|
||||||
|
SalesOrderDetailDO salesOrderDetailDO = SpringUtil.getBean(SalesOrderDetailMapper.class).selectOne(SalesOrderDetailDO::getId, id);
|
||||||
|
return success(BeanUtils.toBean(salesOrderDetailDO, SalesOrdDtlDTO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<List<SalesOrdDtlDTO>> getSalesOrderDetailByIds(List<Long> ids) {
|
||||||
|
List<SalesOrderDetailDO> salesOrderDetailDOS = SpringUtil.getBean(SalesOrderDetailMapper.class).selectList(SalesOrderDetailDO::getId, ids);
|
||||||
|
return success(BeanUtils.toBean(salesOrderDetailDOS, SalesOrdDtlDTO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<PrchOrdDtlDTO> getPoOrderDetailById(Long id) {
|
||||||
|
PrchOrdDtlDO prchOrdDtlDO = SpringUtil.getBean(PrchOrdDtlMapper.class).selectById(id);
|
||||||
|
return success(BeanUtils.toBean(prchOrdDtlDO, PrchOrdDtlDTO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<List<PrchOrdDtlDTO>> getPoOrderDetailByIds(List<Long> ids) {
|
||||||
|
List<PrchOrdDtlDO> prchOrdDtlDOS = SpringUtil.getBean(PrchOrdDtlMapper.class).selectList(PrchOrdDtlDO::getId, ids);
|
||||||
|
return success(BeanUtils.toBean(prchOrdDtlDOS, PrchOrdDtlDTO.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,204 @@
|
|||||||
|
package com.zt.plat.module.contractorder.api;
|
||||||
|
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.module.contractorder.api.dto.order.OrdDtlDTO;
|
||||||
|
import com.zt.plat.module.contractorder.api.dto.order.OrderDTO;
|
||||||
|
import com.zt.plat.module.contractorder.api.dto.order.PurchaseOrderWithDetailsDTO;
|
||||||
|
import com.zt.plat.module.contractorder.api.dto.order.SalesOrdDtlDTO;
|
||||||
|
import com.zt.plat.module.contractorder.dal.dataobject.purchaseorder.PrchOrdDtlDO;
|
||||||
|
import com.zt.plat.module.contractorder.dal.dataobject.purchaseorder.PurchaseOrderDO;
|
||||||
|
import com.zt.plat.module.contractorder.dal.dataobject.salesorder.SalesOrderDO;
|
||||||
|
import com.zt.plat.module.contractorder.dal.dataobject.salesorder.SalesOrderDetailDO;
|
||||||
|
import com.zt.plat.module.contractorder.dal.mysql.purchaseorder.PrchOrdDtlMapper;
|
||||||
|
import com.zt.plat.module.contractorder.dal.mysql.purchaseorder.PurchaseOrderMapper;
|
||||||
|
import com.zt.plat.module.contractorder.dal.mysql.salesorder.SalesOrderDetailMapper;
|
||||||
|
import com.zt.plat.module.contractorder.dal.mysql.salesorder.SalesOrderMapper;
|
||||||
|
import com.zt.plat.module.contractorder.service.purchaseorder.PurchaseOrderService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
public class OrderApiImpl implements OrderApi {
|
||||||
|
@Resource
|
||||||
|
private PurchaseOrderService purchaseOrderService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<List<OrderDTO>> getOrderByOrderIds(List<Long> ids) {
|
||||||
|
if (ids == null || ids.isEmpty()) {
|
||||||
|
throw new RuntimeException("订单id为空");
|
||||||
|
}
|
||||||
|
List<PurchaseOrderDO> ordersByIds = purchaseOrderService.getOrdersByIds(ids.stream().map(String::valueOf).toList());
|
||||||
|
List<Long> purchaseOrderIds = new ArrayList<>();
|
||||||
|
List<Long> salesOrderIds = new ArrayList<>();
|
||||||
|
List<OrderDTO> order = new ArrayList<>();
|
||||||
|
if (ordersByIds.isEmpty()) {
|
||||||
|
return CommonResult.success(new ArrayList<>());
|
||||||
|
}
|
||||||
|
ordersByIds.forEach(o -> {
|
||||||
|
if ("SALE".equals(o.getSplyBsnTp())) {
|
||||||
|
// 销售订单
|
||||||
|
salesOrderIds.add(o.getId());
|
||||||
|
} else {
|
||||||
|
// 非销售订单(采购订单)
|
||||||
|
purchaseOrderIds.add(o.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!purchaseOrderIds.isEmpty()) {
|
||||||
|
order.addAll(getPoOrdByIds(purchaseOrderIds));
|
||||||
|
}
|
||||||
|
if (!salesOrderIds.isEmpty()) {
|
||||||
|
order.addAll(getSalesOrdByIds(salesOrderIds));
|
||||||
|
}
|
||||||
|
return success(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<List<OrderDTO>> getOrderByOrderNos(List<String> orderNoS) {
|
||||||
|
List<PurchaseOrderDO> orderByNos = purchaseOrderService.getOrderByNos(orderNoS);
|
||||||
|
if (orderByNos.isEmpty()) {
|
||||||
|
return success(new ArrayList<>());
|
||||||
|
}
|
||||||
|
List<OrderDTO> order = new ArrayList<>();
|
||||||
|
List<Long> purchaseOrderNoS = new ArrayList<>();
|
||||||
|
List<Long> salesOrdNoS = new ArrayList<>();
|
||||||
|
orderByNos.forEach(f -> {
|
||||||
|
if ("SALE".equals(f.getSplyBsnTp())) {
|
||||||
|
// 销售订单
|
||||||
|
salesOrdNoS.add(f.getId());
|
||||||
|
} else {
|
||||||
|
// 非销售订单(采购订单)
|
||||||
|
purchaseOrderNoS.add(f.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!purchaseOrderNoS.isEmpty()) {
|
||||||
|
order.addAll(getPoOrdByIds(purchaseOrderNoS));
|
||||||
|
}
|
||||||
|
if (!salesOrdNoS.isEmpty()) {
|
||||||
|
order.addAll(getSalesOrdByIds(salesOrdNoS));
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SalesOrderDO> getOrderByIds(List<Long> ids) {
|
||||||
|
return SpringUtil.getBean(SalesOrderMapper.class).selectByIds(ids); // 采购订单与销售订单的
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<OrderDTO> getPoOrdByIds(List<Long> ids) {
|
||||||
|
List<SalesOrderDO> purchaseOrderDOS = getOrderByIds(ids);
|
||||||
|
List<OrderDTO> orderDTOS = BeanUtils.toBean(purchaseOrderDOS, OrderDTO.class);
|
||||||
|
if (orderDTOS == null) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
PrchOrdDtlMapper prchOrdDtlMapper = SpringUtil.getBean(PrchOrdDtlMapper.class);
|
||||||
|
List<Long> orderIds = orderDTOS.stream().map(OrderDTO::getId).toList();
|
||||||
|
List<PrchOrdDtlDO> prchOrdDtlDOS = prchOrdDtlMapper.selectList(PrchOrdDtlDO::getOrdId, orderIds);
|
||||||
|
orderDTOS.forEach(o -> {
|
||||||
|
List<OrdDtlDTO> ordDtlDTOS = new ArrayList<>();
|
||||||
|
prchOrdDtlDOS.forEach(p -> {
|
||||||
|
|
||||||
|
if (Objects.equals(o.getId(), p.getOrdId())) {
|
||||||
|
OrdDtlDTO ordDtlDTO = setOrderDtlDTO(o, p);
|
||||||
|
ordDtlDTOS.add(ordDtlDTO);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
o.setOrdDtlDTOS(ordDtlDTOS);
|
||||||
|
});
|
||||||
|
return orderDTOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<OrderDTO> getSalesOrdByIds(List<Long> ids) {
|
||||||
|
List<SalesOrderDO> salesOrderDOS = getOrderByIds(ids);
|
||||||
|
List<OrderDTO> orderDTOS = BeanUtils.toBean(salesOrderDOS, OrderDTO.class);
|
||||||
|
if (orderDTOS == null) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
SalesOrderDetailMapper salesOrderDetailMapper = SpringUtil.getBean(SalesOrderDetailMapper.class);
|
||||||
|
List<Long> orderIds = orderDTOS.stream().map(OrderDTO::getId).toList();
|
||||||
|
List<SalesOrderDetailDO> salesOrderDetailDOS = salesOrderDetailMapper.selectList(SalesOrderDetailDO::getOrderId, orderIds);
|
||||||
|
orderDTOS.forEach(o -> {
|
||||||
|
List<OrdDtlDTO> salesOrdDtlDTOS = new ArrayList<>();
|
||||||
|
salesOrderDetailDOS.forEach(s -> {
|
||||||
|
if (Objects.equals(o.getId(), s.getOrderId())) {
|
||||||
|
OrdDtlDTO ordDtlDTO = setOrderDtlDTO(o, s);
|
||||||
|
salesOrdDtlDTOS.add(ordDtlDTO);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
o.setOrdDtlDTOS(salesOrdDtlDTOS);
|
||||||
|
});
|
||||||
|
return orderDTOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> OrdDtlDTO setOrderDtlDTO(OrderDTO orderDTO, T t) {
|
||||||
|
OrdDtlDTO ordDtlDTO = new OrdDtlDTO();
|
||||||
|
if (t instanceof PrchOrdDtlDO p) {
|
||||||
|
ordDtlDTO.setId(p.getId());
|
||||||
|
ordDtlDTO.setOrderId(p.getOrdId());
|
||||||
|
ordDtlDTO.setLineNum(p.getLineNum());
|
||||||
|
ordDtlDTO.setMtrlName(p.getMtrlName());
|
||||||
|
ordDtlDTO.setMtrlNum(p.getMtrlNum());
|
||||||
|
ordDtlDTO.setFactoryName(p.getRcvFactNum());
|
||||||
|
ordDtlDTO.setFactoryNum(p.getRcvFactNum());
|
||||||
|
ordDtlDTO.setWarehouseName(p.getRcvWrhNum());
|
||||||
|
ordDtlDTO.setWarehouseNum(p.getRcvWrhNum());
|
||||||
|
ordDtlDTO.setUnit(p.getUnt());
|
||||||
|
ordDtlDTO.setQuantity(p.getQty());
|
||||||
|
ordDtlDTO.setProjectCategory(p.getPrjCtgr());
|
||||||
|
ordDtlDTO.setAgreementNumber(p.getAgrNum());
|
||||||
|
ordDtlDTO.setElementAbbreviation(p.getElemAbbr());
|
||||||
|
ordDtlDTO.setElementName(p.getElemName());
|
||||||
|
ordDtlDTO.setElementCode(p.getElemCdg());
|
||||||
|
ordDtlDTO.setIsEnable(p.getIsEnb());
|
||||||
|
ordDtlDTO.setTaxNum(p.getTaxNum());
|
||||||
|
ordDtlDTO.setTaxRte(p.getTaxRte());
|
||||||
|
//==============================
|
||||||
|
ordDtlDTO.setMtrlCpntNum(p.getMtrlCpntNum());
|
||||||
|
ordDtlDTO.setMtrlCpntDsp(p.getMtrlCpntDsp());
|
||||||
|
ordDtlDTO.setBgnDt(p.getBgnDt());
|
||||||
|
ordDtlDTO.setDdlDt(p.getDdlDt());
|
||||||
|
ordDtlDTO.setTrfFactName(p.getTrfFactName());
|
||||||
|
ordDtlDTO.setTrfFactNum(p.getTrfFactNum());
|
||||||
|
ordDtlDTO.setTrfWrhName(p.getTrfWrhName());
|
||||||
|
ordDtlDTO.setTrfWrhNum(p.getTrfWrhNum());
|
||||||
|
ordDtlDTO.setRmk(p.getRmk());
|
||||||
|
|
||||||
|
|
||||||
|
} else if (
|
||||||
|
t instanceof SalesOrdDtlDTO s
|
||||||
|
) {
|
||||||
|
ordDtlDTO.setId(s.getId());
|
||||||
|
ordDtlDTO.setOrderId(s.getOrderId());
|
||||||
|
ordDtlDTO.setLineNum(s.getLineNumber());
|
||||||
|
ordDtlDTO.setMtrlName(s.getMaterialName());
|
||||||
|
ordDtlDTO.setMtrlNum(s.getMaterialNumber());
|
||||||
|
ordDtlDTO.setFactoryName(s.getFactoryName());
|
||||||
|
ordDtlDTO.setFactoryNum(s.getFactoryNumber());
|
||||||
|
ordDtlDTO.setWarehouseName(s.getWarehouseName());
|
||||||
|
ordDtlDTO.setWarehouseNum(s.getWarehouseNumber());
|
||||||
|
ordDtlDTO.setUnit(s.getUnit());
|
||||||
|
ordDtlDTO.setQuantity(s.getQuantity());
|
||||||
|
ordDtlDTO.setProjectCategory(s.getProjectCategory());
|
||||||
|
ordDtlDTO.setAgreementNumber(s.getAgreementNumber());
|
||||||
|
ordDtlDTO.setElementAbbreviation(s.getElementAbbreviation());
|
||||||
|
ordDtlDTO.setElementName(s.getElementName());
|
||||||
|
ordDtlDTO.setElementCode(s.getElementNumber());
|
||||||
|
ordDtlDTO.setIsEnable(s.getIsEnable());
|
||||||
|
ordDtlDTO.setTaxNum(s.getTaxAcctasscat());
|
||||||
|
//==============================
|
||||||
|
|
||||||
|
}
|
||||||
|
return ordDtlDTO;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.zt.plat.module.contractorder.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||||
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||||
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RestTemplate配置类
|
||||||
|
* @author ChenZhaoxue
|
||||||
|
* @date 2025/3/27
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RestTemplateConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
|
||||||
|
RestTemplate restTemplate = new RestTemplate(factory);
|
||||||
|
restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(Charset.forName("UTF-8")));
|
||||||
|
return restTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
|
||||||
|
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||||
|
factory.setConnectTimeout(10000);//单位为ms
|
||||||
|
factory.setReadTimeout(30000);//单位为ms
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -51,21 +51,21 @@ public class ContractController implements BusinessControllerMarker {
|
|||||||
@GetMapping("/nots")
|
@GetMapping("/nots")
|
||||||
@Operation(summary = "查询不计价规则列表")
|
@Operation(summary = "查询不计价规则列表")
|
||||||
@PreAuthorize("@ss.hasPermission('base:contract:query')")
|
@PreAuthorize("@ss.hasPermission('base:contract:query')")
|
||||||
public CommonResult<List<NotRespVO>> getNots(NotsQueryReqVO queryReqVO) {
|
public CommonResult<PageResult<NotRespVO>> getNots(NotsQueryReqVO queryReqVO) {
|
||||||
return success(contractService.getNots(queryReqVO));
|
return success(contractService.getNots(queryReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/demotes")
|
@GetMapping("/demotes")
|
||||||
@Operation(summary = "查询参数降级规则列表")
|
@Operation(summary = "查询参数降级规则列表")
|
||||||
@PreAuthorize("@ss.hasPermission('base:contract:query')")
|
@PreAuthorize("@ss.hasPermission('base:contract:query')")
|
||||||
public CommonResult<List<DemoteRespVO>> getDemotes(DemotesQueryReqVO queryReqVO) {
|
public CommonResult<PageResult<DemoteRespVO>> getDemotes(DemotesQueryReqVO queryReqVO) {
|
||||||
return success(contractService.getDemotes(queryReqVO));
|
return success(contractService.getDemotes(queryReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/formulas")
|
@GetMapping("/formulas")
|
||||||
@Operation(summary = "查询结算公式列表")
|
@Operation(summary = "查询结算公式列表")
|
||||||
@PreAuthorize("@ss.hasPermission('base:contract:query')")
|
@PreAuthorize("@ss.hasPermission('base:contract:query')")
|
||||||
public CommonResult<List<FormulaRespVO>> getFormulas(FormulasQueryReqVO queryReqVO) {
|
public CommonResult<PageResult<FormulaRespVO>> getFormulas(FormulasQueryReqVO queryReqVO) {
|
||||||
return success(contractService.getFormulas(queryReqVO));
|
return success(contractService.getFormulas(queryReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,20 +144,16 @@ public class PurchaseOrderController implements BusinessControllerMarker {
|
|||||||
@PreAuthorize("@ss.hasPermission('bse:purchase-order:update')")
|
@PreAuthorize("@ss.hasPermission('bse:purchase-order:update')")
|
||||||
public CommonResult<?> submitErp061(@RequestBody @Validated @NotEmpty(message = "采购订单id不能为空") List<String> idsStr) {
|
public CommonResult<?> submitErp061(@RequestBody @Validated @NotEmpty(message = "采购订单id不能为空") List<String> idsStr) {
|
||||||
List<Long> ids = idsStr.stream().map(Long::valueOf).toList();
|
List<Long> ids = idsStr.stream().map(Long::valueOf).toList();
|
||||||
// TODO 推送ERP订单
|
// todo 推送ERP订单
|
||||||
// purchaseOrderService.submitErp061(ids);
|
return success(purchaseOrderService.submitErp061(ids));
|
||||||
//随机生成六位数
|
|
||||||
|
|
||||||
return success(R());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/submit-erp062")
|
@PostMapping("/submit-erp062")
|
||||||
@Operation(summary = "推送ERP订单", description = "062当每次调更新接口后都需要调此接口")
|
@Operation(summary = "推送ERP订单", description = "062当每次调更新接口后都需要调此接口")
|
||||||
@PreAuthorize("@ss.hasPermission('bse:purchase-order:update')")
|
@PreAuthorize("@ss.hasPermission('bse:purchase-order:update')")
|
||||||
public CommonResult<?> submitErp062(@RequestParam @Validated @NotNull(message = "采购订单id不能为空") String id) {
|
public CommonResult<?> submitErp062(@RequestParam @Validated @NotNull(message = "采购订单id不能为空") String id) {
|
||||||
//TODO 推送ERP订单
|
// todo 推送ERP订单
|
||||||
|
return success(purchaseOrderService.submitErp062(Long.valueOf(id)));
|
||||||
return success(R());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//通过订单号查询订单信息
|
//通过订单号查询订单信息
|
||||||
@@ -213,8 +209,5 @@ public class PurchaseOrderController implements BusinessControllerMarker {
|
|||||||
return success(purchaseOrderService.getBindOrderByOrder(reqVO));
|
return success(purchaseOrderService.getBindOrderByOrder(reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String R(){
|
|
||||||
int number = (int) (Math.random() * 900000 + 100000);
|
|
||||||
return String.valueOf(number);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,20 @@ public class SalesOrderController implements BusinessControllerMarker {
|
|||||||
return success(salesOrderRespVO);
|
return success(salesOrderRespVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/order-no")
|
||||||
|
@Operation(summary = "通过订单号获得销售订单")
|
||||||
|
@Parameter(name = "orderNo", description = "订单号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('base:sales-order:query')")
|
||||||
|
public CommonResult<SalesOrderRespVO> getSalesOrderByNo(@RequestParam("orderNo") String orderNo) {
|
||||||
|
SalesOrderDO purchaseOrder = salesOrderService.getSalesOrderByOrderNo(orderNo);
|
||||||
|
SalesOrderRespVO salesOrderRespVO = BeanUtils.toBean(purchaseOrder, SalesOrderRespVO.class);
|
||||||
|
if (salesOrderRespVO == null) {
|
||||||
|
return success(null);
|
||||||
|
}
|
||||||
|
salesOrderService.setSalesOrderDetail(salesOrderRespVO);
|
||||||
|
return success(salesOrderRespVO);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得销售订单分页")
|
@Operation(summary = "获得销售订单分页")
|
||||||
@PreAuthorize("@ss.hasPermission('base:sales-order:query')")
|
@PreAuthorize("@ss.hasPermission('base:sales-order:query')")
|
||||||
@@ -129,8 +143,9 @@ public class SalesOrderController implements BusinessControllerMarker {
|
|||||||
//推送erp091
|
//推送erp091
|
||||||
@PostMapping("/push-erp091")
|
@PostMapping("/push-erp091")
|
||||||
@Operation(summary = "推送erp091")
|
@Operation(summary = "推送erp091")
|
||||||
public CommonResult<Boolean> pushErp091(@RequestParam("id") String id) {
|
public CommonResult<Boolean> pushErp091(@RequestBody @Validated @NotEmpty(message = "销售订单id不能为空") List<String> ids) {
|
||||||
return success(salesOrderService.pushErp091(id));
|
ids.forEach(id -> salesOrderService.pushErp091(id));
|
||||||
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//提交审批
|
//提交审批
|
||||||
|
|||||||
@@ -133,7 +133,6 @@ public class SalesOrderSaveReqVO {
|
|||||||
private String erpSalesCompanyName;
|
private String erpSalesCompanyName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "ERP状态(字典: ERP_REQ_STS)", example = "2")
|
@Schema(description = "ERP状态(字典: ERP_REQ_STS)", example = "2")
|
||||||
private String erpStatus;
|
private String erpStatus;
|
||||||
|
|
||||||
@@ -172,17 +171,10 @@ public class SalesOrderSaveReqVO {
|
|||||||
@ExcelProperty("订单分类")
|
@ExcelProperty("订单分类")
|
||||||
private String splyBsnTp;
|
private String splyBsnTp;
|
||||||
|
|
||||||
/**
|
|
||||||
* 销售组织编码
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Schema(description = "销售组织编码", example = "2")
|
@Schema(description = "销售组织编码", example = "2")
|
||||||
@ExcelProperty("销售组织编码")
|
@ExcelProperty("销售组织编码")
|
||||||
private String saleOrgzCd;
|
private String saleOrgzCd;
|
||||||
/**
|
|
||||||
* 销售组织名称
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Schema(description = "销售组织名称", example = "2")
|
@Schema(description = "销售组织名称", example = "2")
|
||||||
@ExcelProperty("销售组织名称")
|
@ExcelProperty("销售组织名称")
|
||||||
private String saleOrgzName;
|
private String saleOrgzName;
|
||||||
@@ -200,4 +192,10 @@ public class SalesOrderSaveReqVO {
|
|||||||
@Schema(description = "产品组编码")
|
@Schema(description = "产品组编码")
|
||||||
@ExcelProperty("产品组编码")
|
@ExcelProperty("产品组编码")
|
||||||
private String pdtGrpCdg;
|
private String pdtGrpCdg;
|
||||||
|
@Schema(description = "付款方名称")
|
||||||
|
@ExcelProperty("付款方名称")
|
||||||
|
private String payerName;
|
||||||
|
@Schema(description = "付款方编码")
|
||||||
|
@ExcelProperty("付款方编码")
|
||||||
|
private String payerNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,6 +274,6 @@ public class PrchOrdDtlDO extends BusinessBaseDO {
|
|||||||
* 税率
|
* 税率
|
||||||
*/
|
*/
|
||||||
@TableField("TAX_RTE")
|
@TableField("TAX_RTE")
|
||||||
private String taxRte;
|
private BigDecimal taxRte;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,4 +278,9 @@ public class PurchaseOrderDO extends BusinessBaseDO {
|
|||||||
@TableField("SALE_ACS_NAME")
|
@TableField("SALE_ACS_NAME")
|
||||||
private String saleAcsName;
|
private String saleAcsName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税率
|
||||||
|
*/
|
||||||
|
@TableField("TAX_RTE")
|
||||||
|
private BigDecimal taxRte;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ public class SalesOrderDO extends BusinessBaseDO {
|
|||||||
* 付款方名称
|
* 付款方名称
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@TableField("PYER_NUM")
|
@TableField("PYER_NAME")
|
||||||
private String payerName;
|
private String payerName;
|
||||||
/**
|
/**
|
||||||
* 付款方编码
|
* 付款方编码
|
||||||
@@ -303,4 +303,9 @@ public class SalesOrderDO extends BusinessBaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableField("PYER_NUM")
|
@TableField("PYER_NUM")
|
||||||
private String payerNum;
|
private String payerNum;
|
||||||
|
// /**
|
||||||
|
// * 税码
|
||||||
|
// */
|
||||||
|
// @TableField("TAX_NUM")
|
||||||
|
// private String taxNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zt.plat.module.contractorder.dal.mysql.contract;
|
package com.zt.plat.module.contractorder.dal.mysql.contract;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.zt.plat.module.contractorder.api.vo.contract.DemoteRespVO;
|
import com.zt.plat.module.contractorder.api.vo.contract.DemoteRespVO;
|
||||||
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractDemoteDO;
|
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractDemoteDO;
|
||||||
@@ -18,11 +19,21 @@ public interface ContractDemoteMapper extends BaseMapperX<ContractDemoteDO> {
|
|||||||
|
|
||||||
@Select({
|
@Select({
|
||||||
"<script>",
|
"<script>",
|
||||||
"select *",
|
"select ID id",
|
||||||
|
", CTRT_ID contractId",
|
||||||
|
", ELEM_NUM elementNumber",
|
||||||
|
", ELEM_ABBR elementAbbreviation",
|
||||||
|
", ELEM_NAME elementName",
|
||||||
|
", GRD_UP gradeUp",
|
||||||
|
", RNG_WY rangeWay",
|
||||||
|
", GRD_DOWN gradeDown",
|
||||||
|
", MTRL_NAME materialName",
|
||||||
|
", MTRL_NUM materialNumber",
|
||||||
|
", CREATE_TIME createTime",
|
||||||
", (select ctrt_name from BSE_CTRT_MAIN where id = ctrt_id) contractName",
|
", (select ctrt_name from BSE_CTRT_MAIN where id = ctrt_id) contractName",
|
||||||
", (select ctrt_ppr_num from BSE_CTRT_MAIN where id = ctrt_id) contractPaperNumber",
|
", (select ctrt_ppr_num from BSE_CTRT_MAIN where id = ctrt_id) contractPaperNumber",
|
||||||
"from bse_ctrt_dmot",
|
"from bse_ctrt_dmot",
|
||||||
"where 1 = 1",
|
"where DELETED = 0",
|
||||||
"<if test= \"contractIds != null and contractIds.size() > 0\">",
|
"<if test= \"contractIds != null and contractIds.size() > 0\">",
|
||||||
"and ctrt_id in",
|
"and ctrt_id in",
|
||||||
"<foreach collection = 'contractIds' item = 'contractId' open='(' separator = ',' close = ')'>",
|
"<foreach collection = 'contractIds' item = 'contractId' open='(' separator = ',' close = ')'>",
|
||||||
@@ -37,5 +48,5 @@ public interface ContractDemoteMapper extends BaseMapperX<ContractDemoteDO> {
|
|||||||
"</if>",
|
"</if>",
|
||||||
"</script>"
|
"</script>"
|
||||||
})
|
})
|
||||||
List<DemoteRespVO> selectDemotes(List<Long> contractIds, String materialName, String elementName);
|
IPage<DemoteRespVO> selectDemotes(IPage<?> page, List<Long> contractIds, String materialName, String elementName);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zt.plat.module.contractorder.dal.mysql.contract;
|
package com.zt.plat.module.contractorder.dal.mysql.contract;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.zt.plat.module.contractorder.api.vo.contract.FormulaRespVO;
|
import com.zt.plat.module.contractorder.api.vo.contract.FormulaRespVO;
|
||||||
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractFormulaDO;
|
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractFormulaDO;
|
||||||
@@ -18,11 +19,23 @@ public interface ContractFormulaMapper extends BaseMapperX<ContractFormulaDO> {
|
|||||||
|
|
||||||
@Select({
|
@Select({
|
||||||
"<script>",
|
"<script>",
|
||||||
"select *",
|
"select ID id",
|
||||||
|
", CTRT_ID contractId",
|
||||||
|
", FMU_TP formulaType",
|
||||||
|
", FMU_CALT formulaCalculate",
|
||||||
|
", NUM_FMU numberFormula",
|
||||||
|
", MTRL_NAME materialName",
|
||||||
|
", MTRL_NUM materialNumber",
|
||||||
|
", DEC_PNT decimalPoint",
|
||||||
|
", ELEM_NUM elementNumber",
|
||||||
|
", ELEM_ABBR elementAbbreviation",
|
||||||
|
", ELEM_NAME elementName",
|
||||||
|
", STLM_TP settlementType",
|
||||||
|
", CREATE_TIME createTime",
|
||||||
", (select ctrt_name from BSE_CTRT_MAIN where id = ctrt_id) contractName",
|
", (select ctrt_name from BSE_CTRT_MAIN where id = ctrt_id) contractName",
|
||||||
", (select ctrt_ppr_num from BSE_CTRT_MAIN where id = ctrt_id) contractPaperNumber",
|
", (select ctrt_ppr_num from BSE_CTRT_MAIN where id = ctrt_id) contractPaperNumber",
|
||||||
"from bse_ctrt_fmu",
|
"from bse_ctrt_fmu",
|
||||||
"where 1 = 1",
|
"where DELETED = 0",
|
||||||
"<if test= \"contractIds != null and contractIds.size() > 0\">",
|
"<if test= \"contractIds != null and contractIds.size() > 0\">",
|
||||||
"and ctrt_id in",
|
"and ctrt_id in",
|
||||||
"<foreach collection = 'contractIds' item = 'contractId' open='(' separator = ',' close = ')'>",
|
"<foreach collection = 'contractIds' item = 'contractId' open='(' separator = ',' close = ')'>",
|
||||||
@@ -37,5 +50,5 @@ public interface ContractFormulaMapper extends BaseMapperX<ContractFormulaDO> {
|
|||||||
"</if>",
|
"</if>",
|
||||||
"</script>"
|
"</script>"
|
||||||
})
|
})
|
||||||
List<FormulaRespVO> selectFormulas(List<Long> contractIds, String materialName, String elementName);
|
IPage<FormulaRespVO> selectFormulas(IPage<?> page, List<Long> contractIds, String materialName, String elementName);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zt.plat.module.contractorder.dal.mysql.contract;
|
package com.zt.plat.module.contractorder.dal.mysql.contract;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.zt.plat.module.contractorder.api.vo.contract.NotRespVO;
|
import com.zt.plat.module.contractorder.api.vo.contract.NotRespVO;
|
||||||
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractNotDO;
|
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractNotDO;
|
||||||
@@ -18,11 +19,21 @@ public interface ContractNotMapper extends BaseMapperX<ContractNotDO> {
|
|||||||
|
|
||||||
@Select({
|
@Select({
|
||||||
"<script>",
|
"<script>",
|
||||||
"select *",
|
"select ID id",
|
||||||
|
", CTRT_ID contractId",
|
||||||
|
", ELEM_NUM elementNumber",
|
||||||
|
", ELEM_ABBR elementAbbreviation",
|
||||||
|
", ELEM_NAME elementName",
|
||||||
|
", GRD_UP gradeUp",
|
||||||
|
", GRD_DOWN gradeDown",
|
||||||
|
", RNG_WY rangeWay",
|
||||||
|
", MTRL_NAME materialName",
|
||||||
|
", MTRL_NUM materialNumber",
|
||||||
|
", CREATE_TIME createTime",
|
||||||
", (select ctrt_name from BSE_CTRT_MAIN where id = ctrt_id) contractName",
|
", (select ctrt_name from BSE_CTRT_MAIN where id = ctrt_id) contractName",
|
||||||
", (select ctrt_ppr_num from BSE_CTRT_MAIN where id = ctrt_id) contractPaperNumber",
|
", (select ctrt_ppr_num from BSE_CTRT_MAIN where id = ctrt_id) contractPaperNumber",
|
||||||
"from bse_ctrt_nt",
|
"from bse_ctrt_nt",
|
||||||
"where 1 = 1",
|
"where DELETED = 0",
|
||||||
"<if test= \"contractIds != null and contractIds.size() > 0\">",
|
"<if test= \"contractIds != null and contractIds.size() > 0\">",
|
||||||
"and ctrt_id in",
|
"and ctrt_id in",
|
||||||
"<foreach collection = 'contractIds' item = 'contractId' open='(' separator = ',' close = ')'>",
|
"<foreach collection = 'contractIds' item = 'contractId' open='(' separator = ',' close = ')'>",
|
||||||
@@ -37,5 +48,5 @@ public interface ContractNotMapper extends BaseMapperX<ContractNotDO> {
|
|||||||
"</if>",
|
"</if>",
|
||||||
"</script>"
|
"</script>"
|
||||||
})
|
})
|
||||||
List<NotRespVO> selectNots(List<Long> contractIds, String materialName, String elementName);
|
IPage<NotRespVO> selectNots(IPage<NotRespVO> page, List<Long> contractIds, String materialName, String elementName);
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ public interface ContractService {
|
|||||||
* @param queryReqVO 查询参数
|
* @param queryReqVO 查询参数
|
||||||
* @return 不计价规则列表
|
* @return 不计价规则列表
|
||||||
*/
|
*/
|
||||||
List<NotRespVO> getNots(NotsQueryReqVO queryReqVO);
|
PageResult<NotRespVO> getNots(NotsQueryReqVO queryReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询参数降级规则列表
|
* 查询参数降级规则列表
|
||||||
@@ -81,7 +81,7 @@ public interface ContractService {
|
|||||||
* @param queryReqVO 查询参数
|
* @param queryReqVO 查询参数
|
||||||
* @return 参数降级规则列表
|
* @return 参数降级规则列表
|
||||||
*/
|
*/
|
||||||
List<DemoteRespVO> getDemotes(DemotesQueryReqVO queryReqVO);
|
PageResult<DemoteRespVO> getDemotes(DemotesQueryReqVO queryReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询结算公式列表
|
* 查询结算公式列表
|
||||||
@@ -89,7 +89,7 @@ public interface ContractService {
|
|||||||
* @param queryReqVO 查询参数
|
* @param queryReqVO 查询参数
|
||||||
* @return 结算公式列表
|
* @return 结算公式列表
|
||||||
*/
|
*/
|
||||||
List<FormulaRespVO> getFormulas(FormulasQueryReqVO queryReqVO);
|
PageResult<FormulaRespVO> getFormulas(FormulasQueryReqVO queryReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过合同编号获取对应的合同信息
|
* 通过合同编号获取对应的合同信息
|
||||||
@@ -203,10 +203,32 @@ public interface ContractService {
|
|||||||
*/
|
*/
|
||||||
Boolean complete(List<Long> ids);
|
Boolean complete(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合同映射数据提交到erp
|
||||||
|
*
|
||||||
|
* @param erpContractVO 合同映射数据
|
||||||
|
* @return 提交结果
|
||||||
|
*/
|
||||||
JSONObject sendToErp(ErpContractSaveReqVO erpContractVO);
|
JSONObject sendToErp(ErpContractSaveReqVO erpContractVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成合同映射数据
|
||||||
|
*
|
||||||
|
* @param contractMainDO 合同主信息
|
||||||
|
* @return 合同映射信息
|
||||||
|
*/
|
||||||
ErpContractSaveReqVO getErpContract(ContractMainDO contractMainDO);
|
ErpContractSaveReqVO getErpContract(ContractMainDO contractMainDO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成系统合同编号
|
||||||
|
*
|
||||||
|
* 单据号生成规则说明
|
||||||
|
* 单据名称(拼音)-类型-公司编码-年月日-六位编号
|
||||||
|
* 如请款单: QKD-ZGQK-3000-20250915-00001
|
||||||
|
*
|
||||||
|
* @param category 合同类别
|
||||||
|
*
|
||||||
|
* @return 系统合同编号
|
||||||
|
*/
|
||||||
String generateSystemContractNumber(String category);
|
String generateSystemContractNumber(String category);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import cn.hutool.json.JSONArray;
|
|||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
@@ -58,7 +60,6 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -1185,33 +1186,67 @@ public class ContractServiceImpl implements ContractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NotRespVO> getNots(NotsQueryReqVO queryReqVO) {
|
public PageResult<NotRespVO> getNots(NotsQueryReqVO queryReqVO) {
|
||||||
|
|
||||||
// 查合同ID集合
|
// 查合同ID集合
|
||||||
List<Long> contractIds = new ArrayList<>();
|
List<Long> contractIds = new ArrayList<>();
|
||||||
if (StringUtils.isNotEmpty(queryReqVO.getContractName()) || StringUtils.isNotEmpty(queryReqVO.getContractPaperNumber())) {
|
if (StringUtils.isNotEmpty(queryReqVO.getContractName())
|
||||||
|
|| StringUtils.isNotEmpty(queryReqVO.getContractPaperNumber())) {
|
||||||
contractIds = getContractIds(queryReqVO.getContractName(), queryReqVO.getContractPaperNumber());
|
contractIds = getContractIds(queryReqVO.getContractName(), queryReqVO.getContractPaperNumber());
|
||||||
}
|
}
|
||||||
return contractNotMapper.selectNots(contractIds, queryReqVO.getMaterialName(), queryReqVO.getElementName());
|
|
||||||
|
// 分页查询
|
||||||
|
IPage<NotRespVO> ipage = contractNotMapper.selectNots(
|
||||||
|
new Page<NotRespVO>().setCurrent(queryReqVO.getPageNo()).setSize(queryReqVO.getPageSize()),
|
||||||
|
contractIds,
|
||||||
|
queryReqVO.getMaterialName(),
|
||||||
|
queryReqVO.getElementName()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 分页返回
|
||||||
|
return new PageResult<NotRespVO>().setTotal(ipage.getTotal()).setList(ipage.getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DemoteRespVO> getDemotes(DemotesQueryReqVO queryReqVO) {
|
public PageResult<DemoteRespVO> getDemotes(DemotesQueryReqVO queryReqVO) {
|
||||||
|
|
||||||
// 查合同ID集合
|
// 查合同ID集合
|
||||||
List<Long> contractIds = new ArrayList<>();
|
List<Long> contractIds = new ArrayList<>();
|
||||||
if (StringUtils.isNotEmpty(queryReqVO.getContractName()) || StringUtils.isNotEmpty(queryReqVO.getContractPaperNumber())) {
|
if (StringUtils.isNotEmpty(queryReqVO.getContractName()) || StringUtils.isNotEmpty(queryReqVO.getContractPaperNumber())) {
|
||||||
contractIds = getContractIds(queryReqVO.getContractName(), queryReqVO.getContractPaperNumber());
|
contractIds = getContractIds(queryReqVO.getContractName(), queryReqVO.getContractPaperNumber());
|
||||||
}
|
}
|
||||||
return contractDemoteMapper.selectDemotes(contractIds, queryReqVO.getMaterialName(), queryReqVO.getElementName());
|
|
||||||
|
// 分页查询
|
||||||
|
IPage<DemoteRespVO> ipage = contractDemoteMapper.selectDemotes(
|
||||||
|
new Page<>().setCurrent(queryReqVO.getPageNo()).setSize(queryReqVO.getPageSize()),
|
||||||
|
contractIds,
|
||||||
|
queryReqVO.getMaterialName(),
|
||||||
|
queryReqVO.getElementName()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 分页返回
|
||||||
|
return new PageResult<DemoteRespVO>().setTotal(ipage.getTotal()).setList(ipage.getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FormulaRespVO> getFormulas(FormulasQueryReqVO queryReqVO) {
|
public PageResult<FormulaRespVO> getFormulas(FormulasQueryReqVO queryReqVO) {
|
||||||
|
|
||||||
// 查合同ID集合
|
// 查合同ID集合
|
||||||
List<Long> contractIds = new ArrayList<>();
|
List<Long> contractIds = new ArrayList<>();
|
||||||
if (StringUtils.isNotEmpty(queryReqVO.getContractName()) || StringUtils.isNotEmpty(queryReqVO.getContractPaperNumber())) {
|
if (StringUtils.isNotEmpty(queryReqVO.getContractName()) || StringUtils.isNotEmpty(queryReqVO.getContractPaperNumber())) {
|
||||||
contractIds = getContractIds(queryReqVO.getContractName(), queryReqVO.getContractPaperNumber());
|
contractIds = getContractIds(queryReqVO.getContractName(), queryReqVO.getContractPaperNumber());
|
||||||
}
|
}
|
||||||
return contractFormulaMapper.selectFormulas(contractIds, queryReqVO.getMaterialName(), queryReqVO.getElementName());
|
|
||||||
|
// 分页查询
|
||||||
|
IPage<FormulaRespVO> ipage = contractFormulaMapper.selectFormulas(
|
||||||
|
new Page<>().setCurrent(queryReqVO.getPageNo()).setSize(queryReqVO.getPageSize()),
|
||||||
|
contractIds,
|
||||||
|
queryReqVO.getMaterialName(),
|
||||||
|
queryReqVO.getElementName()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 分页返回
|
||||||
|
return new PageResult<FormulaRespVO>().setTotal(ipage.getTotal()).setList(ipage.getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1567,24 +1602,20 @@ public class ContractServiceImpl implements ContractService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 合同映射数据提交到erp
|
|
||||||
*
|
|
||||||
* @param erpContractVO 合同映射数据
|
|
||||||
* @return 提交结果
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject sendToErp(ErpContractSaveReqVO erpContractVO) {
|
public JSONObject sendToErp(ErpContractSaveReqVO erpContractVO) {
|
||||||
JSONObject erpResult = new JSONObject();
|
JSONObject erpResult = new JSONObject();
|
||||||
|
|
||||||
HashMap<String, String> result = erpContractService.submitErp(erpContractVO);
|
// TODO 暂时返回成功
|
||||||
|
erpResult.putOnce("success", true);
|
||||||
|
/*HashMap<String, String> result = erpContractService.submitErp(erpContractVO);
|
||||||
if ("E".equals(result.get("flag"))) {
|
if ("E".equals(result.get("flag"))) {
|
||||||
erpResult.putOnce("success", false);
|
erpResult.putOnce("success", false);
|
||||||
erpResult.putOnce("errMsg", result.get("resStr")+":"+result.get("E_RESP"));
|
erpResult.putOnce("errMsg", result.get("resStr")+":"+result.get("E_RESP"));
|
||||||
} else {
|
} else {
|
||||||
erpResult.putOnce("success", true);
|
erpResult.putOnce("success", true);
|
||||||
erpResult.putOnce("data", result);
|
erpResult.putOnce("data", result);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return erpResult;
|
return erpResult;
|
||||||
}
|
}
|
||||||
@@ -1635,12 +1666,6 @@ public class ContractServiceImpl implements ContractService {
|
|||||||
return operationId;
|
return operationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成合同映射数据
|
|
||||||
*
|
|
||||||
* @param contractMainDO 合同主信息
|
|
||||||
* @return 合同映射信息
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ErpContractSaveReqVO getErpContract(ContractMainDO contractMainDO) {
|
public ErpContractSaveReqVO getErpContract(ContractMainDO contractMainDO) {
|
||||||
|
|
||||||
@@ -1949,17 +1974,6 @@ public class ContractServiceImpl implements ContractService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成系统合同编号
|
|
||||||
*
|
|
||||||
* 单据号生成规则说明
|
|
||||||
* 单据名称(拼音)-类型-公司编码-年月日-六位编号
|
|
||||||
* 如请款单: QKD-ZGQK-3000-20250915-00001
|
|
||||||
*
|
|
||||||
* @param category 合同类别
|
|
||||||
*
|
|
||||||
* @return 系统合同编号
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSystemContractNumber(String category) {
|
public String generateSystemContractNumber(String category) {
|
||||||
|
|
||||||
|
|||||||
@@ -351,18 +351,19 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|||||||
erpOrderSaveReqVO.setItems(items);
|
erpOrderSaveReqVO.setItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 推送ERP并处理返回结果
|
//todo 4. 推送ERP并处理返回结果
|
||||||
String s = erpOrderService.submitOrderToErp061(erpOrderSaveReqVO);
|
// String s = erpOrderService.submitOrderToErp061(erpOrderSaveReqVO);
|
||||||
log.info("订单推送成功,订单id【{}】", order.getId());
|
log.info("订单推送成功,订单id【{}】", order.getId());
|
||||||
|
|
||||||
// 解析ERP返回的ID
|
// 解析ERP返回的ID
|
||||||
JSONObject jsonObject = JSONObject.parseObject(s);
|
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(Map.of("id",R())));
|
||||||
String erpId = jsonObject.getString("id");
|
String erpId = jsonObject.getString("id");
|
||||||
if (erpId != null && !erpId.isEmpty()) {
|
if (erpId != null && !erpId.isEmpty()) {
|
||||||
// 更新订单的ERP编号
|
// 更新订单的ERP编号
|
||||||
PurchaseOrderDO updateDO = new PurchaseOrderDO();
|
PurchaseOrderDO updateDO = new PurchaseOrderDO();
|
||||||
updateDO.setId(order.getId());
|
updateDO.setId(order.getId());
|
||||||
updateDO.setOrderSAPNumber(erpId);
|
updateDO.setOrderSAPNumber(erpId);
|
||||||
|
updateDO.setStatus(OrderStatusEnum.IN_PROGRESS.getCode());
|
||||||
int updateCount = purchaseOrderMapper.updateById(updateDO);
|
int updateCount = purchaseOrderMapper.updateById(updateDO);
|
||||||
if (updateCount > 0) {
|
if (updateCount > 0) {
|
||||||
log.info("更新订单ERPID成功,订单id【{}】", order.getId());
|
log.info("更新订单ERPID成功,订单id【{}】", order.getId());
|
||||||
@@ -786,4 +787,9 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
|
|||||||
return new IllegalArgumentException("BPM状态码不能为null");
|
return new IllegalArgumentException("BPM状态码不能为null");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String R(){
|
||||||
|
int number = (int) (Math.random() * 900000 + 100000);
|
||||||
|
return String.valueOf(number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,4 +121,11 @@ public interface SalesOrderService {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void updateOrderStatusByIdOrOrderNo(OrderStsReqVO req);
|
void updateOrderStatusByIdOrOrderNo(OrderStsReqVO req);
|
||||||
|
/**
|
||||||
|
* 获取订单详情
|
||||||
|
*
|
||||||
|
* @param orderNo 订单编号
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SalesOrderDO getSalesOrderByOrderNo(String orderNo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.module.contractorder.enums.ErrorCodeConstants.CONTRACT_ORDER_EXISTS;
|
import static com.zt.plat.module.contractorder.enums.ErrorCodeConstants.CONTRACT_ORDER_EXISTS;
|
||||||
@@ -242,13 +239,17 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
erpSalesOrderSaveReqVO.setConds(conds);
|
erpSalesOrderSaveReqVO.setConds(conds);
|
||||||
String result = erpOrderService.submitOrderToErp091(erpSalesOrderSaveReqVO);
|
// String result = erpOrderService.submitOrderToErp091(erpSalesOrderSaveReqVO);
|
||||||
|
String result="3333";
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(Map.of("salesdocument",R())));
|
||||||
String salesdocument = jsonObject.getString("salesdocument");
|
String salesdocument = jsonObject.getString("salesdocument");
|
||||||
if (salesdocument != null) {
|
if (salesdocument != null) {
|
||||||
salesOrderDO.setOrderSAPNumber(salesdocument);
|
SalesOrderDO upVo = new SalesOrderDO();
|
||||||
salesOrderMapper.updateById(salesOrderDO);
|
upVo.setId(salesOrderDO.getId());
|
||||||
|
upVo.setOrderSAPNumber(salesdocument);
|
||||||
|
upVo.setStatus(OrderStatusEnum.IN_PROGRESS.getCode());
|
||||||
|
salesOrderMapper.updateById(upVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -523,6 +524,8 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|||||||
salesOrderMapper.update(new LambdaUpdateWrapper<SalesOrderDO>().in(reqVO.getOrderNos() != null, SalesOrderDO::getSystemOrderNumber, reqVO.getOrderNos()).in(reqVO.getIds() != null, SalesOrderDO::getId, reqVO.getIds()).set(SalesOrderDO::getStatus, reqVO.getSts()));
|
salesOrderMapper.update(new LambdaUpdateWrapper<SalesOrderDO>().in(reqVO.getOrderNos() != null, SalesOrderDO::getSystemOrderNumber, reqVO.getOrderNos()).in(reqVO.getIds() != null, SalesOrderDO::getId, reqVO.getIds()).set(SalesOrderDO::getStatus, reqVO.getSts()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void validateSalesOrderNosExists(List<String> orderNos) {
|
private void validateSalesOrderNosExists(List<String> orderNos) {
|
||||||
List<SalesOrderDO> list = salesOrderMapper.selectList(new LambdaQueryWrapper<SalesOrderDO>().in(SalesOrderDO::getSystemOrderNumber, orderNos));
|
List<SalesOrderDO> list = salesOrderMapper.selectList(new LambdaQueryWrapper<SalesOrderDO>().in(SalesOrderDO::getSystemOrderNumber, orderNos));
|
||||||
if (CollUtil.isEmpty(list) || list.size() != orderNos.size()) {
|
if (CollUtil.isEmpty(list) || list.size() != orderNos.size()) {
|
||||||
@@ -540,4 +543,14 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|||||||
})
|
})
|
||||||
.orElseThrow(() -> new IllegalArgumentException("BPM状态码不能为null"));
|
.orElseThrow(() -> new IllegalArgumentException("BPM状态码不能为null"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String R(){
|
||||||
|
int number = (int) (Math.random() * 900000 + 100000);
|
||||||
|
return String.valueOf(number);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SalesOrderDO getSalesOrderByOrderNo(String orderNo) {
|
||||||
|
return salesOrderMapper.selectOne(SalesOrderDO::getSystemOrderNumber, orderNo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,565 @@
|
|||||||
|
package com.zt.plat.module.contractorder.util;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* redis 工具类
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class RedisUtil {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定缓存失效时间
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean expire(String key, long time) {
|
||||||
|
try {
|
||||||
|
if (time > 0) {
|
||||||
|
redisTemplate.expire(key, time, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据key 获取过期时间
|
||||||
|
*
|
||||||
|
* @param key 键 不能为null
|
||||||
|
* @return 时间(秒) 返回0代表为永久有效
|
||||||
|
*/
|
||||||
|
public long getExpire(String key) {
|
||||||
|
return redisTemplate.getExpire(key, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断key是否存在
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return true 存在 false不存在
|
||||||
|
*/
|
||||||
|
public boolean hasKey(String key) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.hasKey(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除缓存
|
||||||
|
*
|
||||||
|
* @param key 可以传一个值 或多个
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void del(String key) {
|
||||||
|
redisTemplate.delete(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================String=============================
|
||||||
|
/**
|
||||||
|
* 普通缓存获取
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
*/
|
||||||
|
public Object get(String key) {
|
||||||
|
return key == null ? null : redisTemplate.opsForValue().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通缓存放入
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @return true成功 false失败
|
||||||
|
*/
|
||||||
|
public boolean set(String key, Object value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForValue().set(key, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通缓存放入并设置时间
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
|
||||||
|
* @return true成功 false 失败
|
||||||
|
*/
|
||||||
|
public boolean set(String key, Object value, long time) {
|
||||||
|
try {
|
||||||
|
if (time > 0) {
|
||||||
|
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
|
||||||
|
} else {
|
||||||
|
set(key, value);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递增
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param by 要增加几(大于0)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long incr(String key, long delta) {
|
||||||
|
if (delta < 0) {
|
||||||
|
throw new RuntimeException("递增因子必须大于0");
|
||||||
|
}
|
||||||
|
return redisTemplate.opsForValue().increment(key, delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递减
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param by 要减少几(小于0)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long decr(String key, long delta) {
|
||||||
|
if (delta < 0) {
|
||||||
|
throw new RuntimeException("递减因子必须大于0");
|
||||||
|
}
|
||||||
|
return redisTemplate.opsForValue().increment(key, -delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================================Map=================================
|
||||||
|
/**
|
||||||
|
* HashGet
|
||||||
|
*
|
||||||
|
* @param key 键 不能为null
|
||||||
|
* @param item 项 不能为null
|
||||||
|
* @return 值
|
||||||
|
*/
|
||||||
|
public Object hget(String key, String item) {
|
||||||
|
return redisTemplate.opsForHash().get(key, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取hashKey对应的所有键值
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return 对应的多个键值
|
||||||
|
*/
|
||||||
|
public Map<Object, Object> hmget(String key) {
|
||||||
|
return redisTemplate.opsForHash().entries(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HashSet
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param map 对应多个键值
|
||||||
|
* @return true 成功 false 失败
|
||||||
|
*/
|
||||||
|
public boolean hmset(String key, Map<String, Object> map) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForHash().putAll(key, map);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HashSet 并设置时间
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param map 对应多个键值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return true成功 false失败
|
||||||
|
*/
|
||||||
|
public boolean hmset(String key, Map<String, Object> map, long time) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForHash().putAll(key, map);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向一张hash表中放入数据,如果不存在将创建
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param item 项
|
||||||
|
* @param value 值
|
||||||
|
* @return true 成功 false失败
|
||||||
|
*/
|
||||||
|
public boolean hset(String key, String item, Object value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForHash().put(key, item, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向一张hash表中放入数据,如果不存在将创建
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param item 项
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
|
||||||
|
* @return true 成功 false失败
|
||||||
|
*/
|
||||||
|
public boolean hset(String key, String item, Object value, long time) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForHash().put(key, item, value);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除hash表中的值
|
||||||
|
*
|
||||||
|
* @param key 键 不能为null
|
||||||
|
* @param item 项 可以使多个 不能为null
|
||||||
|
*/
|
||||||
|
public void hdel(String key, Object... item) {
|
||||||
|
redisTemplate.opsForHash().delete(key, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断hash表中是否有该项的值
|
||||||
|
*
|
||||||
|
* @param key 键 不能为null
|
||||||
|
* @param item 项 不能为null
|
||||||
|
* @return true 存在 false不存在
|
||||||
|
*/
|
||||||
|
public boolean hHasKey(String key, String item) {
|
||||||
|
return redisTemplate.opsForHash().hasKey(key, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hash递增 如果不存在,就会创建一个 并把新增后的值返回
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param item 项
|
||||||
|
* @param by 要增加几(大于0)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public double hincr(String key, String item, double by) {
|
||||||
|
return redisTemplate.opsForHash().increment(key, item, by);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hash递减
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param item 项
|
||||||
|
* @param by 要减少记(小于0)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public double hdecr(String key, String item, double by) {
|
||||||
|
return redisTemplate.opsForHash().increment(key, item, -by);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================set=============================
|
||||||
|
/**
|
||||||
|
* 根据key获取Set中的所有值
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Set<Object> sGet(String key) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForSet().members(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据value从一个set中查询,是否存在
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @return true 存在 false不存在
|
||||||
|
*/
|
||||||
|
public boolean sHasKey(String key, Object value) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForSet().isMember(key, value);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将数据放入set缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param values 值 可以是多个
|
||||||
|
* @return 成功个数
|
||||||
|
*/
|
||||||
|
public long sSet(String key, Object... values) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForSet().add(key, values);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将set数据放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @param values 值 可以是多个
|
||||||
|
* @return 成功个数
|
||||||
|
*/
|
||||||
|
public long sSetAndTime(String key, long time, Object... values) {
|
||||||
|
try {
|
||||||
|
Long count = redisTemplate.opsForSet().add(key, values);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取set缓存的长度
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long sGetSetSize(String key) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForSet().size(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除值为value的
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param values 值 可以是多个
|
||||||
|
* @return 移除的个数
|
||||||
|
*/
|
||||||
|
public long setRemove(String key, Object... values) {
|
||||||
|
try {
|
||||||
|
Long count = redisTemplate.opsForSet().remove(key, values);
|
||||||
|
return count;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ===============================list=================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取list缓存的内容
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param start 开始
|
||||||
|
* @param end 结束 0 到 -1代表所有值
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Object> lGet(String key, long start, long end) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForList().range(key, start, end);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取list缓存的长度
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long lGetListSize(String key) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForList().size(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过索引 获取list中的值
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object lGetIndex(String key, long index) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForList().index(key, index);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将list放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lSet(String key, Object value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().rightPush(key, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将list放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lSet(String key, Object value, long time) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().rightPush(key, value);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将list放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lSet(String key, List<Object> value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().rightPushAll(key, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将list放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lSet(String key, List<Object> value, long time) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().rightPushAll(key, value);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据索引修改list中的某条数据
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param index 索引
|
||||||
|
* @param value 值
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lUpdateIndex(String key, long index, Object value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().set(key, index, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除N个值为value
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param count 移除多少个
|
||||||
|
* @param value 值
|
||||||
|
* @return 移除的个数
|
||||||
|
*/
|
||||||
|
public long lRemove(String key, long count, Object value) {
|
||||||
|
try {
|
||||||
|
Long remove = redisTemplate.opsForList().remove(key, count, value);
|
||||||
|
return remove;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
package com.zt.plat.module.contractorder.util;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ePlat共享服务调用工具类
|
||||||
|
* @author ChenZhaoxue
|
||||||
|
* @date 2025/3/27
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Configuration
|
||||||
|
@Component
|
||||||
|
public class ShareServiceUtil {
|
||||||
|
private static final String SHARE_TOKEN_KEY = "eplat:cache:shareToken";
|
||||||
|
private static final String SHARE_REFRESH_TOKEN_KEY = "eplat:cache:shareRefreshToken";
|
||||||
|
private static final int TOKEN_TIME_OUT = 5000; // token过期时间,默认7200秒,这里设置建议小一些,如7000秒
|
||||||
|
|
||||||
|
@Value("${eplat.share.urlPrex}")
|
||||||
|
private String urlPrex;
|
||||||
|
@Value("${eplat.share.clientId}")
|
||||||
|
private String clientId;
|
||||||
|
@Value("${eplat.share.clientSecret}")
|
||||||
|
private String clientSecret;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ePlat共享服务调用
|
||||||
|
* @param serviceNo 服务号
|
||||||
|
* @param request 请求json字符串
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String callShareService(String serviceNo, String request) {
|
||||||
|
String url = String.format("%s/service/%s", urlPrex, serviceNo);
|
||||||
|
log.info("ePlat共享服务调用url:[" + url + "],request:[" + request + "]");
|
||||||
|
String token = generateToken();
|
||||||
|
log.info("目标token:" + token);
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||||
|
headers.add("Xplat-Token", token);
|
||||||
|
HttpEntity<String> entity = new HttpEntity<>(request, headers);
|
||||||
|
ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
||||||
|
return result.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateToken() {
|
||||||
|
// 先从redis中获取未过期token
|
||||||
|
String token = (String) redisUtil.get(SHARE_TOKEN_KEY);
|
||||||
|
if (token == null) {
|
||||||
|
synchronized (ShareServiceUtil.class) {
|
||||||
|
token = (String) redisUtil.get(SHARE_TOKEN_KEY);
|
||||||
|
if (token == null) {
|
||||||
|
try {
|
||||||
|
token = refreshToken();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("生成token出错,可能刷新token有问题,重新尝试下", e);
|
||||||
|
redisUtil.del(SHARE_REFRESH_TOKEN_KEY);
|
||||||
|
token = refreshToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String refreshToken() {
|
||||||
|
// 先从redis中获取未过期的刷新token
|
||||||
|
String refreshToken = (String) redisUtil.get(SHARE_REFRESH_TOKEN_KEY);
|
||||||
|
if (refreshToken == null) {
|
||||||
|
// 重新创建token和刷新token
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
|
// 构造form表单
|
||||||
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
|
paramsMap.set("client_id", clientId);
|
||||||
|
paramsMap.set("client_secret", clientSecret);
|
||||||
|
paramsMap.set("grant_type", "client_credentials");
|
||||||
|
paramsMap.set("scope", "read");
|
||||||
|
String url = String.format("%s/eplat/oauth/token", urlPrex);
|
||||||
|
// 构造请求的实体。包含body和headers的内容
|
||||||
|
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(paramsMap, headers);
|
||||||
|
log.info("获取token调用url:[" + url + "],request:[" + paramsMap + "]");
|
||||||
|
ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
||||||
|
JSONObject json = JSONUtil.parseObj(result.getBody());
|
||||||
|
String accessToken = json.getStr("access_token");
|
||||||
|
refreshToken = json.getStr("refresh_token");
|
||||||
|
// 缓存token、刷新token(刷新token过期时间为2倍token过期时间)
|
||||||
|
redisUtil.set(SHARE_TOKEN_KEY, accessToken, TOKEN_TIME_OUT);
|
||||||
|
redisUtil.set(SHARE_REFRESH_TOKEN_KEY, refreshToken, TOKEN_TIME_OUT * 2);
|
||||||
|
return accessToken;
|
||||||
|
} else {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
|
// 构造form表单
|
||||||
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
|
paramsMap.set("client_id", clientId);
|
||||||
|
paramsMap.set("client_secret", clientSecret);
|
||||||
|
paramsMap.set("grant_type", "refresh_token");
|
||||||
|
paramsMap.set("refresh_token", refreshToken);
|
||||||
|
String url = String.format("%s/eplat/oauth/token", urlPrex);
|
||||||
|
// 构造请求的实体。包含body和headers的内容
|
||||||
|
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(paramsMap, headers);
|
||||||
|
log.info("刷新token调用url:[" + url + "],request:[" + paramsMap + "]");
|
||||||
|
ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
||||||
|
JSONObject json = JSONUtil.parseObj(result.getBody());
|
||||||
|
String accessToken = json.getStr("access_token");
|
||||||
|
refreshToken = json.getStr("refresh_token");
|
||||||
|
// 缓存token、刷新token(刷新token过期时间为2倍token过期时间)
|
||||||
|
redisUtil.set(SHARE_TOKEN_KEY, accessToken, TOKEN_TIME_OUT);
|
||||||
|
redisUtil.set(SHARE_REFRESH_TOKEN_KEY, refreshToken, TOKEN_TIME_OUT * 2);
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.zt.plat.module.erp.api;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitReqDTO;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitRespDTO;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||||
|
import com.zt.plat.module.erp.enums.ApiConstants;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@FeignClient(name = ApiConstants.NAME)
|
||||||
|
@Tag(name = "RPC 服务 - ERP")
|
||||||
|
public interface InvoiceticketApi {
|
||||||
|
|
||||||
|
String PREFIX = ApiConstants.PREFIX + "/invoiceticket";
|
||||||
|
|
||||||
|
@PostMapping(PREFIX + "/submit")
|
||||||
|
@Operation(summary = "erp数据提交")
|
||||||
|
CommonResult<ErpInvoiceticketSubmitRespDTO> submitDataToErp(@Valid @RequestBody ErpInvoiceticketSubmitReqDTO reqDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.zt.plat.module.erp.api.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "管理后台 - 发票相关操作 Request VO")
|
||||||
|
public class ErpInvoiceticketSubmitReqDTO {
|
||||||
|
@Schema(description = "id,用作bskey", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "发票类型;RE-采购发票,RV-销售发票", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "发票类型不能为空")
|
||||||
|
@Size(min = 2, max = 2, message = "发票类型必须为2位字符")
|
||||||
|
@Pattern(regexp = "^(RE|RV)$", message = "发票类型仅支持RE(采购发票)、RV(销售发票)")
|
||||||
|
private String vouchertype;
|
||||||
|
|
||||||
|
@Schema(description = "发票编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "发票编号不能为空")
|
||||||
|
@Size(min = 1, max = 10, message = "发票编号长度不能超过10位")
|
||||||
|
private String voucherno;
|
||||||
|
|
||||||
|
@Schema(description = "会计年度;发票类型为RE(采购发票)时必填,格式为4位数字(如2025)")
|
||||||
|
@Pattern(regexp = "^\\d{4}$", message = "会计年度必须为4位数字(如2025)")
|
||||||
|
private String voucheryear;
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.zt.plat.module.erp.api.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "管理后台 - 发票相关操作 响应 VO")
|
||||||
|
public class ErpInvoiceticketSubmitRespDTO {
|
||||||
|
@Schema(description = "发票过账日期;格式为YYYYMMDD(如20251106)")
|
||||||
|
private String postDate;
|
||||||
|
|
||||||
|
@Schema(description = "业务单据号;长度20位字符")
|
||||||
|
private String settlementsCode;
|
||||||
|
|
||||||
|
@Schema(description = "状态码;详见《发票状态》表;长度1位字符")
|
||||||
|
private String state;
|
||||||
|
|
||||||
|
@Schema(description = "消息文本;生单失败、驳回、过账失败等状态时返回共享端和SAP消息")
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
@Schema(description = "会计凭证编号;已生成会计凭证的情况下返回;长度10位字符")
|
||||||
|
private String refDoc;
|
||||||
|
|
||||||
|
@Schema(description = "冲销凭证号;状态为已冲销时返回;长度10位字符")
|
||||||
|
private String revDoc;
|
||||||
|
|
||||||
|
@Schema(description = "冲销凭证会计年度;仅RE发票(采购发票)且状态为已冲销时返回;4位数字")
|
||||||
|
private String revYear;
|
||||||
|
|
||||||
|
@Schema(description = "冲销凭证过账日期;状态为已冲销时返回;格式为YYYYMMDD(如20251106)")
|
||||||
|
private String revDate;
|
||||||
|
|
||||||
|
@Schema(description = "采购发票过账差异明细;仅RE发票(采购发票)且状态为3时返回")
|
||||||
|
private List<CallBackSettlementDetail> callBackSettlementDetails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购发票过账差异明细子项
|
||||||
|
*/
|
||||||
|
@Schema(description = "采购发票过账差异明细子项")
|
||||||
|
@Data
|
||||||
|
public static class CallBackSettlementDetail {
|
||||||
|
|
||||||
|
@Schema(description = "工厂编号")
|
||||||
|
private String factoryCode;
|
||||||
|
|
||||||
|
@Schema(description = "物料编号")
|
||||||
|
private String materialCode;
|
||||||
|
|
||||||
|
@Schema(description = "物料凭证号")
|
||||||
|
private String matDoc;
|
||||||
|
|
||||||
|
@Schema(description = "物料描述")
|
||||||
|
private String materialDesc;
|
||||||
|
|
||||||
|
@Schema(description = "差异金额")
|
||||||
|
private BigDecimal differenceAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.zt.plat.module.erp.api;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitReqDTO;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitRespDTO;
|
||||||
|
import com.zt.plat.module.erp.service.erp.ErpInvoiceticketService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
public class InvoiceticketImpl implements InvoiceticketApi {
|
||||||
|
@Resource
|
||||||
|
private ErpInvoiceticketService erpInvoiceticketService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<ErpInvoiceticketSubmitRespDTO> submitDataToErp(ErpInvoiceticketSubmitReqDTO reqDTO) {
|
||||||
|
return success(erpInvoiceticketService.sbumitToErp020(reqDTO));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.zt.plat.module.erp.service.erp;
|
||||||
|
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitReqDTO;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitRespDTO;
|
||||||
|
|
||||||
|
public interface ErpInvoiceticketService {
|
||||||
|
ErpInvoiceticketSubmitRespDTO sbumitToErp020(ErpInvoiceticketSubmitReqDTO reqDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package com.zt.plat.module.erp.service.erp;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
|
import com.zt.plat.module.erp.api.ErpExternalApi;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitReqDTO;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitRespDTO;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class ErpInvoiceticketServiceImpl implements ErpInvoiceticketService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
public ErpExternalApi erpExternalApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErpInvoiceticketSubmitRespDTO sbumitToErp020(ErpInvoiceticketSubmitReqDTO erpInvoiceticketSubmitReqDTO) {
|
||||||
|
ErpSubmitReqDTO reqDTO = new ErpSubmitReqDTO();
|
||||||
|
reqDTO.setFuncnr("020");
|
||||||
|
reqDTO.setBskey(erpInvoiceticketSubmitReqDTO.getId());
|
||||||
|
reqDTO.setUsrid(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
|
||||||
|
reqDTO.setUsrnm((SecurityFrameworkUtils.getLoginUserNickname()));
|
||||||
|
|
||||||
|
Map<String, Object> req = new HashMap<>();
|
||||||
|
req.put("vouchertype", erpInvoiceticketSubmitReqDTO.getVouchertype());
|
||||||
|
req.put("voucherno", erpInvoiceticketSubmitReqDTO.getVoucherno());
|
||||||
|
req.put("voucheryear", erpInvoiceticketSubmitReqDTO.getVoucheryear());
|
||||||
|
reqDTO.setReq(req);
|
||||||
|
// 1. 调用ERP接口获取HashMap结果
|
||||||
|
|
||||||
|
HashMap<String, String> result = erpExternalApi.submitDataToErp(reqDTO);
|
||||||
|
|
||||||
|
// 2. 初始化响应实体
|
||||||
|
ErpInvoiceticketSubmitRespDTO respDTO = new ErpInvoiceticketSubmitRespDTO();
|
||||||
|
|
||||||
|
// 3. 基础字段映射(String类型直接赋值,兼容空值)
|
||||||
|
respDTO.setPostDate(getStringValue(result, "postDate"));
|
||||||
|
respDTO.setSettlementsCode(getStringValue(result, "settlementsCode"));
|
||||||
|
respDTO.setState(getStringValue(result, "state"));
|
||||||
|
respDTO.setReason(getStringValue(result, "reason"));
|
||||||
|
respDTO.setRefDoc(getStringValue(result, "refDoc"));
|
||||||
|
respDTO.setRevDoc(getStringValue(result, "revDoc"));
|
||||||
|
respDTO.setRevYear(getStringValue(result, "revYear"));
|
||||||
|
respDTO.setRevDate(getStringValue(result, "revDate"));
|
||||||
|
|
||||||
|
// 4. 子列表 callBackSettlementDetails 映射
|
||||||
|
respDTO.setCallBackSettlementDetails(convertSettlementDetails(result));
|
||||||
|
|
||||||
|
return respDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换采购发票过账差异明细列表
|
||||||
|
* 假设HashMap中子列表字段格式为:callBackSettlementDetails[0].factoryCode、callBackSettlementDetails[0].materialCode...
|
||||||
|
*/
|
||||||
|
private List<ErpInvoiceticketSubmitRespDTO.CallBackSettlementDetail> convertSettlementDetails(Map<String, String> result) {
|
||||||
|
List<ErpInvoiceticketSubmitRespDTO.CallBackSettlementDetail> detailList = new ArrayList<>();
|
||||||
|
if (result == null) {
|
||||||
|
return detailList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按索引遍历子列表数据,直到无对应字段为止
|
||||||
|
int index = 0;
|
||||||
|
while (true) {
|
||||||
|
// 拼接子字段的key(根据实际返回的key格式调整,此处为标准嵌套格式)
|
||||||
|
String factoryCodeKey = String.format("callBackSettlementDetails[%d].factoryCode", index);
|
||||||
|
String materialCodeKey = String.format("callBackSettlementDetails[%d].materialCode", index);
|
||||||
|
String matDocKey = String.format("callBackSettlementDetails[%d].matDoc", index);
|
||||||
|
String materialDescKey = String.format("callBackSettlementDetails[%d].materialDesc", index);
|
||||||
|
String differenceAmountKey = String.format("callBackSettlementDetails[%d].differenceAmount", index);
|
||||||
|
|
||||||
|
// 若核心字段(如factoryCode)为空,说明无更多子项,退出循环
|
||||||
|
if (StringUtils.isBlank(getStringValue(result, factoryCodeKey))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建子明细实体
|
||||||
|
ErpInvoiceticketSubmitRespDTO.CallBackSettlementDetail detail = new ErpInvoiceticketSubmitRespDTO.CallBackSettlementDetail();
|
||||||
|
detail.setFactoryCode(getStringValue(result, factoryCodeKey));
|
||||||
|
detail.setMaterialCode(getStringValue(result, materialCodeKey));
|
||||||
|
detail.setMatDoc(getStringValue(result, matDocKey));
|
||||||
|
detail.setMaterialDesc(getStringValue(result, materialDescKey));
|
||||||
|
// 金额字段转换(兼容空值和非数字场景)
|
||||||
|
detail.setDifferenceAmount(getBigDecimalValue(result, differenceAmountKey));
|
||||||
|
|
||||||
|
detailList.add(detail);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 无数据时返回null,避免前端接收空列表
|
||||||
|
return detailList.isEmpty() ? null : detailList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全获取String值,避免null指针
|
||||||
|
*/
|
||||||
|
private String getStringValue(Map<String, String> map, String key) {
|
||||||
|
return map.getOrDefault(key, StringUtils.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全转换BigDecimal,处理空值和格式错误
|
||||||
|
*/
|
||||||
|
private BigDecimal getBigDecimalValue(Map<String, String> map, String key) {
|
||||||
|
String value = map.get(key);
|
||||||
|
if (StringUtils.isBlank(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return new BigDecimal(value);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 若金额格式错误,可根据业务选择返回null或抛出异常
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user