修改-根据多个排单号查询板材数据

This commit is contained in:
liuzhaotian
2024-06-25 16:01:18 +08:00
parent 9fee8cceee
commit 2f43b11fee
8 changed files with 62 additions and 10 deletions
@@ -8,6 +8,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -15,7 +16,7 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
public class GetPlateByPlanIdVO extends PageParam {
@Schema(description = "排单id")
@NotNull(message = "排单id不能空")
private Long planId;
private List<Long> planIds;
@Schema(description = "矩形")
private Boolean rectangle;
@Schema(description = "异形")
@@ -423,7 +423,12 @@ public class PlanServiceImpl implements PlanService {
@Override
public PageResult<PlateResList> getPlateByPlanId(GetPlateByPlanIdVO vo) {
validatePlanExists(vo.getPlanId());
if(vo.getPlanIds().isEmpty()){
return null;
}
for (Long planId : vo.getPlanIds()) {
validatePlanExists(planId);
}
QueryWrapperX<PlateDO> queryWrapperX = new QueryWrapperX<>();
List<Integer> filterTypes = new ArrayList<>();
if (Objects.nonNull(vo.getHoleThrough()) && vo.getHoleThrough()) {
@@ -436,7 +441,7 @@ public class PlanServiceImpl implements PlanService {
filterTypes.add(PlanFilterTypeEnum.TWODIMENSIONALCUTTINGPATH.getType());
}
queryWrapperX.eq("p.plan_id", vo.getPlanId())
queryWrapperX.in("p.plan_id", vo.getPlanIds())
.eq("a.organ_id",getUserOrganId())
.eqIfPresent("a.is_door", vo.getIsDoor())
.eqIfPresent("a.is_special_shaped", vo.getSpecialShaped())
@@ -26,6 +26,8 @@ public class PlateDetailsRespVO {
@Schema(description = "柜体ID", requiredMode = Schema.RequiredMode.REQUIRED)
private String bodyId;
@Schema(description = "板材ID", requiredMode = Schema.RequiredMode.REQUIRED)
private String plateId;
@Schema(description = "板编号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("板编号")
@@ -17,7 +17,7 @@ import lombok.*;
@AllArgsConstructor
public class OrderDO extends BaseDO {
@TableId()
@TableId
// 生产单号
private Long id;
@@ -47,7 +47,7 @@ public interface ProductionStatusMapper extends BaseMapperX<OrderDO> {
default List<OrderDO> selectPackPage(PackPageReqVO pageReqVO,Long organId) {
return selectList(new LambdaQueryWrapperX<OrderDO>()
.eq(OrderDO::getOrganId,organId)
.eqIfPresent(OrderDO::getId, pageReqVO.getOrderId())
.likeIfPresent(OrderDO::getId, String.valueOf(pageReqVO.getOrderId()))
.eqIfPresent(OrderDO::getCustomOrderNo, pageReqVO.getCustomOrderNo())
.likeIfPresent(OrderDO::getCustomer, pageReqVO.getCustomer())
.likeIfPresent(OrderDO::getAddress, pageReqVO.getAddress())
@@ -114,7 +114,8 @@
<resultMap id="PlateDetailsMap" type="com.cf.imes.module.manage.controller.admin.pack.vo.PlateDetailsRespVO">
<result property="roomName" column="roomName"/>
<result property="cabinetName" column="bodyName"/>
<result property="plateNo" column="plateId"/>
<result property="plateId" column="plateId"/>
<result property="plateNo" column="plateNo"/>
<result property="plateName" column="plateName"/>
<result property="material" column="plateMaterial"/>
<result property="color" column="plateColor"/>
@@ -137,6 +138,7 @@
ob.room_name as roomName,
ob.name as bodyName,
op.id as plateId,
op.plate_no as plateNo,
op.name as plateName,
ogs.material as plateMaterial,
ogs.color as plateColor,
@@ -46,6 +46,14 @@ public interface ErrorCodeConstants {
ErrorCode USER_COUNT_MAX = new ErrorCode(1_002_003_008, "创建用户失败,原因:超过组织最大组织配额({})!");
ErrorCode USER_ME_ERROR = new ErrorCode(1_002_003_009, "不可操作用户自身");
ErrorCode THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_6_CHARACTERS = new ErrorCode(1_002_003_010, "密码长度必须至少为6个字符");
ErrorCode THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LETTER = new ErrorCode(1_002_003_011, "密码必须包含至少一个字母");
ErrorCode THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_NUMBER = new ErrorCode(1_002_003_012, "密码必须包含至少一个数字");
ErrorCode PASSWORDS_CAN_ONLY_CONTAIN_LETTERS_AND_NUMBERS = new ErrorCode(1_002_003_013, "密码只能包含字母和数字");
// ========== 部门模块 1-002-004-000 ==========
ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门");
ErrorCode DEPT_PARENT_NOT_EXITS = new ErrorCode(1_002_004_001,"父级部门不存在");
@@ -49,6 +49,7 @@ import javax.annotation.Resource;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.*;
import java.util.regex.Pattern;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertList;
@@ -88,6 +89,13 @@ public class AdminUserServiceImpl implements AdminUserService {
@Resource
private FileApi fileApi;
// 定义密码校验的正则表达式
private static final String LENGTH_PATTERN = ".{6,}";
private static final String LETTER_PATTERN = ".*[A-Za-z].*";
private static final String DIGIT_PATTERN = ".*\\d.*";
private static final String VALID_CHAR_PATTERN = "^[A-Za-z\\d]+$";
@Override
@Transactional(rollbackFor = Exception.class)
public Long createUser(UserSaveReqVO createReqVO) {
@@ -102,7 +110,7 @@ public class AdminUserServiceImpl implements AdminUserService {
});
// 校验正确性
validateUserForCreateOrUpdate(null, createReqVO.getUsername(),
createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds(), organId);
createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds(),createReqVO.getPassword(), organId);
// 插入用户
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
user.setOrganId(createReqVO.getOrganId());
@@ -131,7 +139,7 @@ public class AdminUserServiceImpl implements AdminUserService {
updateReqVO.setPassword(null); // 特殊:此处不更新密码
// 校验正确性
validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(),
updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds(), organId);
updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds(),null, organId);
// 更新用户
AdminUserDO updateObj = BeanUtils.toBean(updateReqVO, AdminUserDO.class);
@@ -187,6 +195,8 @@ public class AdminUserServiceImpl implements AdminUserService {
public void updateUserPassword(Long id, UserProfileUpdatePasswordReqVO reqVO) {
// 校验旧密码密码
validateOldPassword(id, reqVO.getOldPassword());
// 校验密码是否符合要求
validatePassword(reqVO.getNewPassword());
// 执行更新
AdminUserDO updateObj = new AdminUserDO().setId(id);
updateObj.setPassword(encodePassword(reqVO.getNewPassword())); // 加密密码
@@ -349,9 +359,11 @@ public class AdminUserServiceImpl implements AdminUserService {
}
private void validateUserForCreateOrUpdate(Long id, String username, String mobile, String email,
Long deptId, Set<Long> postIds, Long organId) {
Long deptId, Set<Long> postIds,String password ,Long organId) {
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
DataPermissionUtils.executeIgnore(() -> {
// 校验用户的密码是否符合规则
validatePassword(password);
// 校验用户存在
validateUserExists(id);
// 校验用户名唯一
@@ -367,6 +379,28 @@ public class AdminUserServiceImpl implements AdminUserService {
});
}
@VisibleForTesting
void validatePassword(String password){
// 检查密码长度
if (!Pattern.matches(LENGTH_PATTERN, password)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_6_CHARACTERS);
}
// 检查是否包含字母
if (!Pattern.matches(LETTER_PATTERN, password)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LETTER);
}
// 检查是否包含数字
if (!Pattern.matches(DIGIT_PATTERN, password)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_NUMBER);
}
// 检查是否只包含字母和数字
if (!Pattern.matches(VALID_CHAR_PATTERN, password)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.PASSWORDS_CAN_ONLY_CONTAIN_LETTERS_AND_NUMBERS);
}
}
@VisibleForTesting
void validateUserExists(Long id) {
if (id == null) {
@@ -462,7 +496,7 @@ public class AdminUserServiceImpl implements AdminUserService {
// 校验,判断是否有不符合的原因
try {
validateUserForCreateOrUpdate(null, null, importUser.getMobile(), importUser.getEmail(),
importUser.getDeptId(), null, organId);
importUser.getDeptId(), null,null, organId);
} catch (ServiceException ex) {
respVO.getFailureUsernames().put(importUser.getUsername(), ex.getMessage());
return;