Compare commits

...

6 Commits

Author SHA1 Message Date
YBP
8de87161ad 修改记录查询 2026-03-26 11:46:00 +08:00
shusir
56eb717371 fix:存放位置数据权限调整 2026-03-26 10:26:59 +08:00
shusir
b93a5741a1 fix:物料盘点出入库因事务将private改为public 2026-03-26 10:22:57 +08:00
YBP
0f288f65a4 添加管理员角色常量 2026-03-26 09:52:19 +08:00
shusir
9244510903 Merge remote-tracking branch 'origin/test' into test 2026-03-25 18:08:52 +08:00
shusir
4fa4371f0c fix:物料抽象出实例的入库方法 2026-03-25 18:08:06 +08:00
23 changed files with 203 additions and 170 deletions

View File

@@ -24,4 +24,6 @@ public interface QmsPermissionConstant {
String SAMPLE_WAREHOUSE_ADMIN = "sample_warehouse_admin"; //样品库管理员
String DEVICE_MANAGER = "qms_device_manager"; //设备管理员
String ADMIN_ROLE = "ytjyAdmin"; // 超级管理员 标识
}

View File

@@ -61,6 +61,9 @@ public class ConfigWarehouseLocationPageReqVO extends PageParam {
@Schema(description = "查询时进行权限过滤")
private String permissionFilterFlag;
@Schema(description = "是否为管理员-可查看全部数据")
private Boolean adminFlag;
@Schema(description = "查询用-权限角色")
private Set<Long> roleIds;

View File

@@ -16,6 +16,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.stream.Collectors;
/**
* 存放位置 Mapper
@@ -29,9 +30,7 @@ public interface ConfigWarehouseLocationMapper extends BaseMapperX<ConfigWarehou
MPJLambdaWrapperX<ConfigWarehouseLocationDO> wrapper = new MPJLambdaWrapperX<>();
//仓库
wrapper.leftJoin(ConfigWarehouseLocationParDO.class, ConfigWarehouseLocationParDO::getId, ConfigWarehouseLocationDO::getParentId)
// 权限
.leftJoin(ConfigPermissionDO.class, ConfigPermissionDO::getSourceId, ConfigWarehouseLocationDO::getId);
wrapper.leftJoin(ConfigWarehouseLocationParDO.class, ConfigWarehouseLocationParDO::getId, ConfigWarehouseLocationDO::getParentId);
wrapper.selectAll(ConfigWarehouseLocationDO.class)
.selectAs(ConfigWarehouseLocationParDO::getName, ConfigWarehouseLocationRespVO::getWarehouseName)
.selectAs(ConfigWarehouseLocationParDO::getCode, ConfigWarehouseLocationRespVO::getWarehouseCode)
@@ -48,12 +47,19 @@ public interface ConfigWarehouseLocationMapper extends BaseMapperX<ConfigWarehou
.eqIfPresent(ConfigWarehouseLocationDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
.betweenIfPresent(ConfigWarehouseLocationDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(ConfigWarehouseLocationDO::getRemark, reqVO.getRemark())
// 角色权限
.and(CollUtil.isNotEmpty(reqVO.getRoleIds()), wrapper1 ->
wrapper1.in(ConfigPermissionDO::getTargetId, reqVO.getRoleIds())
.or()
.eqIfExists(ConfigWarehouseLocationDO::getCreator, SecurityFrameworkUtils.getLoginUserId()))
.orderByDesc(ConfigWarehouseLocationDO::getSortNo);
;
Boolean adminFlag = reqVO.getAdminFlag();
// 角色权限 - 使用 exists 子查询
if (adminFlag == null || !adminFlag && CollUtil.isNotEmpty(reqVO.getRoleIds())) {
String roleIdsStr = reqVO.getRoleIds().stream()
.map(String::valueOf)
.collect(Collectors.joining(","));
wrapper.and(wrapper1 ->
wrapper1.exists("SELECT 1 FROM t_cfg_perm WHERE t_cfg_perm.SRC_ID = t.ID AND t_cfg_perm.deleted = 0 AND t_cfg_perm.TGT_ID IN (" + roleIdsStr + ")")
);
}
wrapper.orderByDesc(ConfigWarehouseLocationDO::getSortNo);
return selectJoinPage(reqVO, ConfigWarehouseLocationRespVO.class, wrapper);
}

View File

@@ -3,6 +3,7 @@ package com.zt.plat.module.qms.business.config.service;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zt.plat.framework.common.biz.system.permission.PermissionCommonApi;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
import com.zt.plat.module.qms.business.config.controller.vo.ConfigPermissionSaveReqVO;
@@ -12,6 +13,7 @@ import com.zt.plat.module.qms.business.config.controller.vo.ConfigWarehouseLocat
import com.zt.plat.module.qms.enums.QmsPermissionConstant;
import com.zt.plat.module.qms.enums.QmsWarehouseLocationConstant;
import com.zt.plat.module.system.api.permission.PermissionApi;
import com.zt.plat.module.system.api.permission.RoleApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
@@ -45,6 +47,8 @@ public class ConfigWarehouseLocationServiceImpl implements ConfigWarehouseLocati
@Autowired
private PermissionApi permissionApi;
@Autowired
private PermissionCommonApi permissionCommonApi;
@Override
public ConfigWarehouseLocationRespVO save(ConfigWarehouseLocationSaveReqVO reqVo) {
@@ -182,6 +186,8 @@ public class ConfigWarehouseLocationServiceImpl implements ConfigWarehouseLocati
// 获取当前用户角色
CommonResult<Set<Long>> userRoleIds = permissionApi.getUserRoleIdListByUserId(SecurityFrameworkUtils.getLoginUserId());
pageReqVO.setRoleIds(userRoleIds.getData());
CommonResult<Boolean> hasAnyRoles = permissionCommonApi.hasAnyRoles(SecurityFrameworkUtils.getLoginUserId(), QmsPermissionConstant.ADMIN_ROLE);
pageReqVO.setAdminFlag(hasAnyRoles.getData());
return configWarehouseLocationMapper.selectPage(pageReqVO);
}

View File

@@ -54,7 +54,7 @@ public interface MaterialInventoryCheckDetailMapper extends BaseMapperX<Material
.eqIfPresent(MaterialInventoryCheckDetailDO::getDisposalMethod, reqVO.getDisposalMethod())
.eqIfPresent(MaterialInventoryCheckDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
.betweenIfPresent(MaterialInventoryCheckDetailDO::getCreateTime, reqVO.getCreateTime())
.orderByAsc(MaterialInventoryCheckDetailDO::getPresent)
.orderByDesc(MaterialInventoryCheckDetailDO::getPresent)
.orderByDesc(MaterialInventoryCheckDetailDO::getId);
return selectJoinPage(reqVO, MaterialInventoryCheckDetailRespVO.class, wrapper);

View File

@@ -9,6 +9,8 @@ import lombok.Getter;
public enum MaterialInboundType {
acceptance_inbound("验收入库"),
hzrd_make_inbound("危化品配置入库"),
check_inbound("盘点入库");
private final String name;
@@ -17,8 +19,8 @@ public enum MaterialInboundType {
this.name = name;
}
public static MaterialFlowType fromName(String name) {
for (MaterialFlowType type : MaterialFlowType.values()) {
public static MaterialInboundType fromName(String name) {
for (MaterialInboundType type : MaterialInboundType.values()) {
if (type.getName().equals(name)) {
return type;
}

View File

@@ -149,10 +149,9 @@ public interface MaterialInfomationService {
*
* @param product 大类信息
* @param totalOperationQuantity 总操作数量
* @param productId 大类id
* @return 物料信息
*/
MaterialInfomationDO saveMaterialInfomationByHzrdMtrlMake(MaterialProductDO product, BigDecimal totalOperationQuantity, Long productId);
MaterialInfomationDO saveMaterialInfomationByHzrdMtrlMake(MaterialProductDO product, BigDecimal totalOperationQuantity);
/**
* 批量保存物料信息 - 标准溶液配置生成生成

View File

@@ -232,13 +232,13 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService
}
@Override
public MaterialInfomationDO saveMaterialInfomationByHzrdMtrlMake(MaterialProductDO product, BigDecimal totalOperationQuantity, Long productId) {
public MaterialInfomationDO saveMaterialInfomationByHzrdMtrlMake(MaterialProductDO product, BigDecimal totalOperationQuantity) {
MaterialInfomationDO infomationDO = BeanUtils.toBean(product, MaterialInfomationDO.class);
infomationDO
.setId(null)
.setInitialVolume(totalOperationQuantity)
.setRemainingVolume(totalOperationQuantity)
.setProductId(productId)
.setProductId(product.getId())
.setCode(this.getInfomationCode(product.getCustomConfig()))
.setManufacturerDate(LocalDate.now())
.setExpirationDate(LocalDate.now().plusDays(product.getDue()))

View File

@@ -4,8 +4,9 @@ import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundPageReqVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundRespVO;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryInboundSaveReqVO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryInboundDO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialLifecycleDO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
import jakarta.validation.Valid;
import java.math.BigDecimal;
@@ -77,4 +78,15 @@ public interface MaterialInventoryInboundService {
* @param inbounds 入库
*/
void saveBatch(List<MaterialInventoryInboundDO> inbounds);
/**
* 入库物料实例
*
* @param inbound 入库信息
* @param product 需要入库的大类
* @param totalQuantity 实例的总量
* @param infomations 需要入库的物料实例
* @return 物料实例
*/
List<MaterialInfomationDO> inboundInfomation(MaterialInventoryInboundDO inbound, MaterialProductDO product, BigDecimal totalQuantity, List<MaterialInfomationDO> infomations);
}

View File

@@ -20,24 +20,16 @@ import com.zt.plat.module.qms.resource.material.dal.dataobject.*;
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryInboundMapper;
import com.zt.plat.module.qms.resource.material.enums.MaterialAcceptStatus;
import com.zt.plat.module.qms.resource.material.enums.MaterialInboundType;
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.user.AdminUserApi;
import com.zt.plat.module.system.api.user.dto.AdminUserRespDTO;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*;
@@ -146,6 +138,46 @@ public class MaterialInventoryInboundServiceImpl implements MaterialInventoryInb
materialInventoryInboundMapper.insertBatch(inbounds);
}
@Override
public List<MaterialInfomationDO> inboundInfomation(MaterialInventoryInboundDO inboundInfo, MaterialProductDO product, BigDecimal totalOperationQuantity, List<MaterialInfomationDO> infomations) {
MaterialInboundType inboundType = MaterialInboundType.fromName(inboundInfo.getBusinessType());
// 1. 保存入库单
materialInventoryInboundMapper.insert(inboundInfo);
if (inboundType == MaterialInboundType.hzrd_make_inbound) {
MaterialInfomationDO infomation = materialInfomationService.saveMaterialInfomationByHzrdMtrlMake(product, totalOperationQuantity);
MaterialInventoryInboundDetailDO detailDO = new MaterialInventoryInboundDetailDO()
.setInboundId(inboundInfo.getId())
.setMaterialInfomationId(infomation.getId())
.setInboundUserName(inboundInfo.getApplyUser())
.setInboundUserId(inboundInfo.getApplyUserId())
.setInboundDepartmentName(inboundInfo.getApplyDepartment())
.setInboundDepartmentId(inboundInfo.getApplyDepartmentId())
.setInboundTime(LocalDateTime.now())
.setRemark(inboundInfo.getRemark());
materialInventoryInboundDetailService.saveBatch(List.of(detailDO));
return List.of(infomation);
} else if (inboundType == MaterialInboundType.check_inbound) {
// 保存入库明细
List<MaterialInventoryInboundDetailDO> inboundDetails = infomations.stream()
.map(inf -> new MaterialInventoryInboundDetailDO()
.setInboundId(inboundInfo.getId())
.setMaterialInfomationId(inf.getId())
.setInboundUserName(inboundInfo.getApplyUser())
.setInboundUserId(inboundInfo.getApplyUserId())
.setInboundDepartmentName(inboundInfo.getApplyDepartment())
.setInboundDepartmentId(inboundInfo.getApplyDepartmentId())
.setInboundTime(LocalDateTime.now())
.setRemark(inboundInfo.getRemark()))
.toList();
materialInventoryInboundDetailService.saveBatch(inboundDetails);
// 更新物料在库状态
List<Long> infIds = infomations.stream().map(MaterialInfomationDO::getId).toList();
materialInfomationService.updateByIds(infIds, new MaterialInfomationDO().setUsageStatus(0));
}
return List.of();
}
private MaterialInventoryInboundDO getInbound(MaterialInventoryInboundSaveReqVO createReqVO, MaterialBatchDO gongDO) {
MaterialInventoryInboundDO inbound = BeanUtils.toBean(createReqVO, MaterialInventoryInboundDO.class);
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();

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