fix:物料大类的实例配单独的编号规则;

This commit is contained in:
shusir
2026-03-17 16:25:33 +08:00
parent 1f4f44af00
commit 7f2b6ea261
16 changed files with 152 additions and 40 deletions

View File

@@ -180,7 +180,7 @@ public interface ErrorCodeConstants {
ErrorCode MATERIAL_INFOMATION_NOT_EXISTS = new ErrorCode(1_032_160_000, "试剂耗材不存在"); ErrorCode MATERIAL_INFOMATION_NOT_EXISTS = new ErrorCode(1_032_160_000, "试剂耗材不存在");
ErrorCode MATERIAL_PRODUCT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料分类/大类不存在"); ErrorCode MATERIAL_PRODUCT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料分类/大类不存在");
ErrorCode MATERIAL_PRODUCT_PARENT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料分类/大类的父类不存在"); ErrorCode MATERIAL_PRODUCT_PARENT_NOT_EXISTS = new ErrorCode(1_032_160_000, "物料分类/大类的父类不存在");
ErrorCode MATERIAL_PRODUCT_CODE_MODELNO_EXISTED = new ErrorCode(1_032_160_000, "物料大类【编码+型号】重复"); ErrorCode MATERIAL_PRODUCT_CODE_SPECIFICATION_EXISTED = new ErrorCode(1_032_160_000, "物料大类【编码+规格】重复");
ErrorCode MATERIAL_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_032_160_000, "分类下含有子分类或物料大类,不可删除"); ErrorCode MATERIAL_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_032_160_000, "分类下含有子分类或物料大类,不可删除");
ErrorCode MATERIAL_PRODUCT_EXISTS_BATCH = new ErrorCode(1_032_160_000, "物料大类下存在物料批次,不可删除"); ErrorCode MATERIAL_PRODUCT_EXISTS_BATCH = new ErrorCode(1_032_160_000, "物料大类下存在物料批次,不可删除");
ErrorCode MATERIAL_PRODUCTS_EXISTS_CATEGORY = new ErrorCode(1_032_160_000, "物料大类列表中存在分类数据"); ErrorCode MATERIAL_PRODUCTS_EXISTS_CATEGORY = new ErrorCode(1_032_160_000, "物料大类列表中存在分类数据");

View File

@@ -215,6 +215,7 @@ public class QMSMultiDataPermissionHandler implements MultiDataPermissionHandler
// 添加到上下文中,避免重复计算 // 添加到上下文中,避免重复计算
loginUser.setContext(QMS_PERMISSION_CONTEXT_KEY, qmsDataPermission); loginUser.setContext(QMS_PERMISSION_CONTEXT_KEY, qmsDataPermission);
} }
Long ctxDeptId = DeptContextHolder.getDeptId(); Long ctxDeptId = DeptContextHolder.getDeptId();
// 计算有效的部门与自查标记:当存在上下文部门且未被忽略时,强制仅使用该部门,以避免默认全量或空权限分支 // 计算有效的部门与自查标记:当存在上下文部门且未被忽略时,强制仅使用该部门,以避免默认全量或空权限分支
Set<Long> effectiveDeptIds = qmsDataPermission.getDeptIds(); Set<Long> effectiveDeptIds = qmsDataPermission.getDeptIds();
@@ -234,9 +235,10 @@ public class QMSMultiDataPermissionHandler implements MultiDataPermissionHandler
} }
// 情况二:仅在有效部门集合为空且不可查看自己时,才认为无权限;若上下文提供部门,则跳过该兜底 // 情况二:仅在有效部门集合为空且不可查看自己时,才认为无权限;若上下文提供部门,则跳过该兜底
if (CollUtil.isEmpty(effectiveDeptIds) && Boolean.FALSE.equals(effectiveSelf)) { // TODO 这个逻辑暂时先注释,好像是存在用户角色时,不会设置部门
return new EqualsTo(null, null); // WHERE null = null可以保证返回的数据为空 // if (CollUtil.isEmpty(effectiveDeptIds) && Boolean.FALSE.equals(effectiveSelf)) {
} // return new EqualsTo(null, null); // WHERE null = null可以保证返回的数据为空
// }
// 情况三,拼接 Dept 和 Company User 的条件,最后组合 // 情况三,拼接 Dept 和 Company User 的条件,最后组合
Expression deptExpression = buildDeptExpression(tableName, deptIdCol, tableAlias, effectiveDeptIds); Expression deptExpression = buildDeptExpression(tableName, deptIdCol, tableAlias, effectiveDeptIds);

View File

@@ -153,7 +153,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
MaterialBatchImportExcelVO.builder() MaterialBatchImportExcelVO.builder()
.productName("无水硼砂") .productName("无水硼砂")
.productCode("W11174909") .productCode("W11174909")
.productModelNo("95%") .productSpecification("95%")
.supplier("供应商 1") .supplier("供应商 1")
.manufacturerDate(LocalDate.parse("2026-03-15")) .manufacturerDate(LocalDate.parse("2026-03-15"))
.dueDate(LocalDate.parse("2026-08-11")) .dueDate(LocalDate.parse("2026-08-11"))
@@ -164,7 +164,7 @@ public class MaterialBatchController implements BusinessControllerMarker {
MaterialBatchImportExcelVO.builder() MaterialBatchImportExcelVO.builder()
.productName("氧化钙") .productName("氧化钙")
.productCode("W10102372") .productCode("W10102372")
.productModelNo("AR500g/瓶") .productSpecification("AR")
.supplier("供应商 2") .supplier("供应商 2")
.manufacturerDate(LocalDate.parse("2026-04-16")) .manufacturerDate(LocalDate.parse("2026-04-16"))
.dueDate(LocalDate.parse("2026-09-18")) .dueDate(LocalDate.parse("2026-09-18"))

View File

@@ -1,12 +1,18 @@
package com.zt.plat.module.qms.resource.material.controller.admin; package com.zt.plat.module.qms.resource.material.controller.admin;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONObject;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationRespVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationSaveReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationSaveReqVO;
import com.zt.plat.module.qms.resource.material.controller.vo.export.MaterialLedgerExportVO;
import com.zt.plat.module.qms.resource.material.controller.vo.query.MaterialInfomationQueryVO; import com.zt.plat.module.qms.resource.material.controller.vo.query.MaterialInfomationQueryVO;
import com.zt.plat.module.qms.resource.material.controller.vo.resp.MaterialInfomationLedgerRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.resp.MaterialInfomationLedgerRespVO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
import com.zt.plat.module.qms.resource.material.service.MaterialInfomationService; import com.zt.plat.module.qms.resource.material.service.MaterialInfomationService;
import lombok.extern.slf4j.Slf4j;
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;
@@ -35,6 +41,7 @@ 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.*;
@Slf4j
@Tag(name = "管理后台 - 物料实例") @Tag(name = "管理后台 - 物料实例")
@RestController @RestController
@RequestMapping("/qms/resource/material-infomation") @RequestMapping("/qms/resource/material-infomation")
@@ -126,18 +133,33 @@ public class MaterialInfomationController implements BusinessControllerMarker {
} }
@GetMapping("/export-ledger") @GetMapping("/export-ledger")
@Operation(summary = "导出危化品台账") @Operation(summary = "导出台账")
public void exportHazardousLedger(@Valid MaterialInfomationPageReqVO pageReqVO, HttpServletResponse response) throws IOException { public void exportHazardousLedger(@Valid MaterialInfomationPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
// ArrayList<MaterialHazardousLedgerExportVO> exportVOS = getLedgerExportVOS();
// 暂时只获取危化品台账 // 暂时只获取危化品台账
pageReqVO.setHazardous(1); pageReqVO.setHazardous(1);
PageResult<MaterialInfomationLedgerRespVO> pageResult = materialInfomationService.getMaterialInventoryLedgerPage(pageReqVO); PageResult<MaterialInfomationLedgerRespVO> pageResult = materialInfomationService.getMaterialInventoryLedgerPage(pageReqVO);
// // 3. 导出 Excel
// ComplexExcelUtils.writeHazardousLedger( // 导出 Excel
// response, "危险化学品管理台账.xls", "危险化学品管理台账", exportVOS List<MaterialInfomationLedgerRespVO> list = pageResult.getList();
// if (CollUtil.isEmpty(list)) {
// ); ExcelUtils.write(response, "物料危化品库存台账.xls", "危化品库存台账", MaterialLedgerExportVO.class,
BeanUtils.toBean(list, MaterialLedgerExportVO.class));
return;
}
List<MaterialLedgerExportVO> exportVOS = list.stream().map(respVO -> {
MaterialLedgerExportVO exportVO = BeanUtils.toBean(respVO, MaterialLedgerExportVO.class);
JSONObject productCustomConfig = respVO.getProductCustomConfig();
if (productCustomConfig == null) return exportVO;
MaterialLedgerExportVO extraProps = productCustomConfig.get("extraProps", MaterialLedgerExportVO.class);
if (extraProps == null) return exportVO;
BeanUtil.copyProperties(extraProps, exportVO, CopyOptions.create().setIgnoreNullValue(true));
return exportVO;
}).toList();
ExcelUtils.write(response, "物料危化品库存台账.xls", "危化品库存台账",
MaterialLedgerExportVO.class,
exportVOS);
} }
} }

View File

@@ -1,12 +1,10 @@
package com.zt.plat.module.qms.resource.material.controller.vo; package com.zt.plat.module.qms.resource.material.controller.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam; import com.zt.plat.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;

View File

@@ -42,6 +42,10 @@ public class MaterialBatchRespVO {
@ExcelProperty("物料大类编码") @ExcelProperty("物料大类编码")
private String productCode; private String productCode;
@Schema(description = "物料大类规格")
@ExcelProperty("物料大类规格")
private String productSpecification;
@Schema(description = "物料大类型号") @Schema(description = "物料大类型号")
@ExcelProperty("物料大类型号") @ExcelProperty("物料大类型号")
private String productModelNo; private String productModelNo;
@@ -94,6 +98,10 @@ public class MaterialBatchRespVO {
@ExcelProperty("供应商id") @ExcelProperty("供应商id")
private Long supplierId; private Long supplierId;
@Schema(description = "供应商")
@ExcelProperty("供应商")
private String supplierName;
@Schema(description = "生产日期") @Schema(description = "生产日期")
@ExcelProperty("生产日期") @ExcelProperty("生产日期")
private LocalDateTime manufacturerDate; private LocalDateTime manufacturerDate;

View File

@@ -26,8 +26,8 @@ public class MaterialBatchImportExcelVO {
@ExcelProperty("物料编码") @ExcelProperty("物料编码")
private String productCode; private String productCode;
@ExcelProperty("物料型号") @ExcelProperty("物料规格")
private String productModelNo; private String productSpecification;
@ExcelProperty("供应商") @ExcelProperty("供应商")
private String supplier; private String supplier;

View File

@@ -134,6 +134,16 @@ public class MaterialInfomationDO extends BusinessBaseDO {
@TableField("MNGR_USER_NAME") @TableField("MNGR_USER_NAME")
private String managerUserName; private String managerUserName;
/** /**
* 所属部门id
*/
@TableField("BLG_DEPT_ID")
private Long belongDepartmentId;
/**
* 所属部门
*/
@TableField("BLG_DEPT_NAME")
private String belongDepartmentName;
/**
* 开封状态,0-未开封1-已开封 * 开封状态,0-未开封1-已开封
*/ */
@TableField("OPN_STS") @TableField("OPN_STS")

View File

@@ -11,6 +11,7 @@ import com.zt.plat.framework.security.core.LoginUser;
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
import com.zt.plat.module.qms.core.aspect.annotation.QmsPermission; import com.zt.plat.module.qms.core.aspect.annotation.QmsPermission;
import com.zt.plat.module.qms.enums.QmsCommonConstant; import com.zt.plat.module.qms.enums.QmsCommonConstant;
import com.zt.plat.module.qms.office.supplier.dal.dataobject.SupplierDO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO;
@@ -48,7 +49,7 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
.orderByDesc(MaterialBatchDO::getId)); .orderByDesc(MaterialBatchDO::getId));
} }
@QmsPermission(moduleDataRoleCodes = "ytjyAdmin", deptIdColumn = "ASN_DEPT_ID") @QmsPermission(deptIdColumn = "ASN_DEPT_ID")
default PageResult<MaterialBatchRespVO> selectPageWithPdtInfo(MaterialBatchPageReqVO reqVO, List<Long> pdtIds) { default PageResult<MaterialBatchRespVO> selectPageWithPdtInfo(MaterialBatchPageReqVO reqVO, List<Long> pdtIds) {
MPJLambdaWrapper<MaterialBatchDO> wrapper = new MPJLambdaWrapperX<MaterialBatchDO>() MPJLambdaWrapper<MaterialBatchDO> wrapper = new MPJLambdaWrapperX<MaterialBatchDO>()
@@ -56,14 +57,17 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatchDO> {
.selectAs(MaterialProductDO::getName, MaterialBatchRespVO::getProductName) .selectAs(MaterialProductDO::getName, MaterialBatchRespVO::getProductName)
.selectAs(MaterialProductDO::getCode, MaterialBatchRespVO::getProductCode) .selectAs(MaterialProductDO::getCode, MaterialBatchRespVO::getProductCode)
.selectAs(MaterialProductDO::getStandardCapacity, MaterialBatchRespVO::getStandardCapacity) .selectAs(MaterialProductDO::getStandardCapacity, MaterialBatchRespVO::getStandardCapacity)
.selectAs(MaterialProductDO::getSpecification, MaterialBatchRespVO::getProductSpecification)
.selectAs(MaterialProductDO::getModelNo, MaterialBatchRespVO::getProductModelNo) .selectAs(MaterialProductDO::getModelNo, MaterialBatchRespVO::getProductModelNo)
// 标签模板,用于入库 // 标签模板,用于入库
.selectAs(MaterialProductDO::getLabelTemplateKey, MaterialBatchRespVO::getLabelTemplateKey) .selectAs(MaterialProductDO::getLabelTemplateKey, MaterialBatchRespVO::getLabelTemplateKey)
// 生产日期和到期日期,用于验收和入库 // 生产日期和到期日期,用于验收和入库
.selectAs("batch.MFR_DT", MaterialBatchDO::getManufacturerDate) .selectAs("batch.MFR_DT", MaterialBatchDO::getManufacturerDate)
.selectAs("batch.DUE_DT", MaterialBatchDO::getDueDate) .selectAs("batch.DUE_DT", MaterialBatchDO::getDueDate)
.selectAs(SupplierDO::getName, MaterialBatchRespVO::getSupplierName)
.leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialBatchDO::getProductId) .leftJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialBatchDO::getProductId)
.leftJoin(MaterialBatchDO.class, "batch", MaterialBatchDO::getId, MaterialBatchDO::getParentId) .leftJoin(MaterialBatchDO.class, "batch", MaterialBatchDO::getId, MaterialBatchDO::getParentId)
.leftJoin(SupplierDO.class, SupplierDO::getId, MaterialBatchDO::getSupplierId)
// 只要批次 // 只要批次
.eq(MaterialBatchGongType.batch.name().equals(reqVO.getDataType()), MaterialBatchDO::getParentId, 0) .eq(MaterialBatchGongType.batch.name().equals(reqVO.getDataType()), MaterialBatchDO::getParentId, 0)
// 只要工段 // 只要工段

View File

@@ -7,6 +7,7 @@ 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.framework.mybatis.core.query.MPJLambdaWrapperX; import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigWarehouseLocationDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigWarehouseLocationDO;
import com.zt.plat.module.qms.core.aspect.annotation.QmsPermission;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceConfigBusinessRuleDO; import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceConfigBusinessRuleDO;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceProductDO; import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceProductDO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO;
@@ -55,6 +56,7 @@ public interface MaterialInfomationMapper extends BaseMapperX<MaterialInfomation
.orderByDesc(MaterialInfomationDO::getId)); .orderByDesc(MaterialInfomationDO::getId));
} }
@QmsPermission(deptIdColumn = "BLG_DEPT_ID")
default PageResult<MaterialInfomationRespVO> selectPageWithPdtInfo(MaterialInfomationPageReqVO reqVO) { default PageResult<MaterialInfomationRespVO> selectPageWithPdtInfo(MaterialInfomationPageReqVO reqVO) {
MPJLambdaWrapper<MaterialInfomationDO> wrapper = new MPJLambdaWrapperX<MaterialInfomationDO>() MPJLambdaWrapper<MaterialInfomationDO> wrapper = new MPJLambdaWrapperX<MaterialInfomationDO>()
.select(MaterialInfomationDO::getId, .select(MaterialInfomationDO::getId,
@@ -233,7 +235,7 @@ public interface MaterialInfomationMapper extends BaseMapperX<MaterialInfomation
default PageResult<MaterialInfomationLedgerRespVO> selectInventoryLedgerPage(MaterialInfomationPageReqVO reqVO) { default PageResult<MaterialInfomationLedgerRespVO> selectInventoryLedgerPage(MaterialInfomationPageReqVO reqVO) {
MPJLambdaWrapper<MaterialInfomationDO> wrapper = new MPJLambdaWrapperX<MaterialInfomationDO>() MPJLambdaWrapper<MaterialInfomationDO> wrapper = new MPJLambdaWrapperX<MaterialInfomationDO>()
.select(MaterialInfomationDO::getProductId) .select(MaterialInfomationDO::getProductId)
.selectAs(MaterialInfomationDO::getDeptId, MaterialInfomationLedgerRespVO::getDepartmentId) .selectAs(MaterialInfomationDO::getBelongDepartmentId, MaterialInfomationLedgerRespVO::getDepartmentId)
.select(MaterialInfomationDO::getLocationId) .select(MaterialInfomationDO::getLocationId)
.selectCount(MaterialInfomationDO::getId, MaterialInfomationLedgerRespVO::getDepartmentInventoryQuantity) .selectCount(MaterialInfomationDO::getId, MaterialInfomationLedgerRespVO::getDepartmentInventoryQuantity)
.innerJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialInfomationDO::getProductId) .innerJoin(MaterialProductDO.class, MaterialProductDO::getId, MaterialInfomationDO::getProductId)
@@ -241,7 +243,7 @@ public interface MaterialInfomationMapper extends BaseMapperX<MaterialInfomation
.eq(MaterialInfomationDO::getUsageStatus, 0) .eq(MaterialInfomationDO::getUsageStatus, 0)
.likeIfExists(MaterialProductDO::getName, reqVO.getName()) .likeIfExists(MaterialProductDO::getName, reqVO.getName())
.groupBy(MaterialInfomationDO::getProductId, .groupBy(MaterialInfomationDO::getProductId,
MaterialInfomationDO::getDeptId, MaterialInfomationDO::getBelongDepartmentId,
MaterialInfomationDO::getLocationId); MaterialInfomationDO::getLocationId);
return selectJoinPage(reqVO, MaterialInfomationLedgerRespVO.class, wrapper); return selectJoinPage(reqVO, MaterialInfomationLedgerRespVO.class, wrapper);

Some files were not shown because too many files have changed in this diff Show More