Merge branch 'main' of ssh://192.168.1.205:9922/cf_devdept2/cf_imes_server

This commit is contained in:
lym
2024-10-17 10:08:55 +08:00
52 changed files with 343 additions and 1105 deletions
@@ -1,6 +1,5 @@
package com.cf.imes.module.system.controller.admin.auth.vo;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.validation.InEnum;
import com.cf.imes.module.system.enums.social.SocialTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -33,9 +32,6 @@ public class AuthLoginReqVO {
@NotEmpty(message = "密码不能为空")
private String password;
@Schema(description = "组织名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰科技")
private String organName;
// ========== 图片验证码相关 ==========
@Schema(description = "验证码,验证码开启时,需要传递", requiredMode = Schema.RequiredMode.REQUIRED,
@@ -1,22 +1,28 @@
package com.cf.imes.module.system.controller.admin.dept.vo.post;
import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.module.system.validation.common.CommonStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Size;
@Schema(description = "管理后台 - 岗位分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
public class PostPageReqVO extends PageParam {
@Schema(description = "岗位编码,模糊匹配", example = "chenfeng")
@Size(max = 64, message = "岗位编码长度不能超过64个字符")
private String code;
@Schema(description = "岗位名称,模糊匹配", example = "晨丰")
@Size(max = 50, message = "岗位名称长度不能超过50个字符")
private String name;
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
@CommonStatus
private Integer status;
private Long organId;
@@ -1,7 +1,6 @@
package com.cf.imes.module.system.controller.admin.dept.vo.post;
import com.cf.imes.framework.common.enums.CommonStatusEnum;
import com.cf.imes.framework.common.validation.InEnum;
import com.cf.imes.module.system.validation.common.CommonStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -31,10 +30,11 @@ public class PostSaveReqVO {
private Integer sort;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@InEnum(CommonStatusEnum.class)
@CommonStatus
private Integer status;
@Schema(description = "备注", example = "快乐的备注")
@Size(max = 256, message = "备注长度不能超过256个字符")
private String remark;
}
@@ -12,6 +12,7 @@ import com.cf.imes.module.system.controller.admin.label.vo.LabelRespVO;
import com.cf.imes.module.system.controller.admin.label.vo.LabelSaveReqVO;
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
import com.cf.imes.module.system.service.lable.LabelService;
import com.cf.imes.module.system.validation.label.LabelTemplateTypeValid;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -87,7 +88,7 @@ public class LabelController {
@Parameter(name = "type", description = "类型", required = false, example = "1024")
//@PreAuthorize("@ss.hasPermission('system:label:query')")
@OperateLog(enable = false)
public CommonResult<List<LabelRespVO>> getList(@RequestParam("type") String type) {
public CommonResult<List<LabelRespVO>> getList(@RequestParam("type") @LabelTemplateTypeValid String type) {
return success(BeanUtils.toBean(labelService.list(type), LabelRespVO.class));
}
@@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -18,12 +19,15 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
public class LabelPageReqVO extends PageParam {
@Schema(description = "标签类型", example = "2")
@Size(max = 32, message = "标签类型长度不能超过32个字符")
private String type;
@Schema(description = "标签名称", example = "王五")
@Size(max = 50, message = "标签名称长度不能超过50个字符")
private String name;
@Schema(description = "备注", example = "你猜")
@Size(max = 255, message = "备注长度不能超过255个字符")
private String remark;
@Schema(description = "宽度")
@@ -1,12 +1,11 @@
package com.cf.imes.module.system.controller.admin.label.vo;
import co.elastic.clients.elasticsearch.watcher.DeactivateWatchRequest;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
import javax.validation.constraints.Size;
@Schema(description = "管理后台 - 标签模板新增/修改 Request VO")
@Data
@@ -17,14 +16,17 @@ public class LabelSaveReqVO {
@Schema(description = "标签类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "标签类型不能为空")
@Size(max = 32, message = "标签类型长度不能超过32个字符")
private String type;
@Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "标签名称不能为空")
@Size(max = 50, message = "标签名称长度不能超过50个字符")
private String name;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
@NotEmpty(message = "备注不能为空")
@Size(max = 255, message = "备注长度不能超过255个字符")
private String remark;
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
@@ -10,6 +10,7 @@ import com.cf.imes.module.system.controller.admin.machine.vo.*;
import com.cf.imes.module.system.dal.dataobject.machine.MachineDO;
import com.cf.imes.module.system.service.machine.MachineService;
import com.cf.imes.module.system.service.machine.MachineTemplateService;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -119,7 +120,7 @@ public class MachineController {
@GetMapping("getBrandAndModel")
@Operation(summary = "获得机台的品牌跟型号")
//@PreAuthorize("@ss.hasPermission('machine::query')")
public CommonResult<List<MachineBrandModelRespVO>> getBrandAndModel(@RequestParam Integer type) {
public CommonResult<List<MachineBrandModelRespVO>> getBrandAndModel(@RequestParam @MachineTypeValid Integer type) {
return success(machineService.getBrandAndModel(type));
}
@@ -1,12 +1,15 @@
package com.cf.imes.module.system.controller.admin.machine.vo;
import com.alibaba.fastjson.JSONObject;
import com.cf.imes.framework.es.core.valid.CreateGroup;
import com.cf.imes.framework.es.core.valid.UpdateGroup;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* @author there
@@ -21,13 +24,16 @@ public class CuttingSaveReqVO {
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "名称不能为空")
@Size(max = 100, message = "名称长度不能超过100个字符")
private String name;
@Schema(description = "1开料机台设备 2钻孔机台设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "1开料机台设备 2钻孔机台设备 不能为空")
@MachineTypeValid
private Integer machineType;
@Schema(description = "标签id")
@NotNull(message = "标签id不能空")
private Long labelId;
// // 新的机台逻辑需要删除
@@ -36,6 +42,7 @@ public class CuttingSaveReqVO {
// private Long templateId;
@Schema(description = "品牌ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "品牌ID不能为空")
private Long brandId;
@@ -47,6 +54,7 @@ public class CuttingSaveReqVO {
@Schema(description = "机台的型号-机台的ID")
@NotNull(message = "机台型号不能为空",groups = CreateGroup.class)
private Long machineId;
@@ -2,11 +2,13 @@ package com.cf.imes.module.system.controller.admin.machine.vo;
import com.alibaba.fastjson.JSONObject;
import com.cf.imes.framework.es.core.valid.UpdateGroup;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* @author there
@@ -19,18 +21,21 @@ public class CuttingTemplateSaveReqVO {
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "名称不能为空")
@Size(max = 100, message = "名称长度不能超过100个字符")
private String name;
@Schema(description = "1开料机台设备 2钻孔机台设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "1开料机台设备 2钻孔机台设备 不能为空")
@MachineTypeValid
private Integer machineType;
@Schema(description = "当前品牌ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "当前品牌ID不能为空")
private Long nowBrandId;
@Schema(description = "引用的品牌ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@Schema(description = "引用的品牌ID", example = "2")
private Long brandId;
@@ -50,7 +55,7 @@ public class CuttingTemplateSaveReqVO {
// private String model;
@Schema(description = "机台的型号-机台ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@Schema(description = "机台的型号-机台ID", example = "2")
private Long machineId;
@@ -3,6 +3,8 @@ package com.cf.imes.module.system.controller.admin.machine.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author Beal
*/
@@ -10,26 +12,32 @@ import lombok.Data;
public class MachineOrgAuthReq {
@Schema(description = "组织id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "组织id不能为空")
private Long organId;
@Schema(description = "开料机授权数量")
@NotNull(message = "开料机授权数量不能为空")
private Integer cutLimit;
@Schema(description = "钻孔机授权数量")
@NotNull(message = "钻孔机授权数量不能为空")
private Integer drillLimit;
@Schema(description = "贴标机授权数量")
@NotNull(message = "贴标机授权数量不能为空")
private Integer labelLimit;
@Schema(description = "裁板锯授权数量")
@NotNull(message = "裁板锯授权数量不能为空")
private Integer sawLimit;
@Schema(description = "封边机授权数量")
@NotNull(message = "封边机授权数量不能为空")
private Integer sealedgeLimit;
@@ -1,10 +1,12 @@
package com.cf.imes.module.system.controller.admin.machine.vo;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.cf.imes.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -16,9 +18,11 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
public class MachinePageReqVO extends PageParam {
@Schema(description = "名称", example = "王五")
@Size(max = 100, message = "名称长度不能超过100个字符")
private String name;
@Schema(description = "1机台设备 2CNC设备", example = "2")
@MachineTypeValid
private Integer machineType;
@Schema(description = "创建时间")
@@ -1,10 +1,12 @@
package com.cf.imes.module.system.controller.admin.machine.vo;
import com.cf.imes.module.system.validation.machine.MachineTypeValid;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
@Data
@@ -16,6 +18,7 @@ public class MachineTemplateBrandReqVO {
@Schema(description = "1开料机台设备 2钻孔机台设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "1开料机台设备 2钻孔机台设备 不能为空")
@MachineTypeValid
private Integer machineType;
@Schema(description = "机台的品牌ID")
@@ -24,6 +27,7 @@ public class MachineTemplateBrandReqVO {
@Schema(description = "机台的品牌", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "品牌名称不能为空")
@Size(max = 64, message = "品牌名称长度不能超过64个字符")
private String brand;
@@ -1,6 +1,7 @@
package com.cf.imes.module.system.controller.admin.machine.vo;
import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.module.system.validation.common.CommonStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -10,10 +11,11 @@ import lombok.Data;
@Data
public class OrganMachinePage extends PageParam {
@Schema(description = "组织名称")
@Schema(description = "组织编号")
private Long organId;
@Schema(description = "组织状态(0正常 1停用)")
@CommonStatus
private Integer status;
}
@@ -9,7 +9,6 @@ import com.cf.imes.framework.common.util.servlet.ServletUtils;
import com.cf.imes.framework.common.util.validation.ValidationUtils;
import com.cf.imes.module.system.api.logger.dto.LoginLogCreateReqDTO;
import com.cf.imes.module.system.api.sms.SmsCodeApi;
import com.cf.imes.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
import com.cf.imes.module.system.api.social.dto.SocialUserBindReqDTO;
import com.cf.imes.module.system.api.social.dto.SocialUserRespDTO;
import com.cf.imes.module.system.controller.admin.auth.vo.AuthLoginReqVO;
@@ -105,8 +104,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
// 校验机构有效性
organService.validOrgan(user.getOrganId());
// 校验密码
String userPassword = user.getPassword();
if (StringUtils.isNotEmpty(userPassword) && !userService.isPasswordMatch(password, userPassword)) {
if (!userService.isPasswordMatch(password, user.getPassword())) {
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AUTH_LOGIN_BAD_CREDENTIALS);
}
@@ -1,6 +1,7 @@
package com.cf.imes.module.system.service.machine;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cf.imes.framework.common.enums.CommonStatusEnum;
@@ -148,7 +149,11 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
// MachineBrandDO machineBrandDO = machineBrandMapper.selectById(reqVO.getId());
List<MachineTemplateDO> machineTemplateDOS = machineTemplateMapper.selectByBrand(reqVO.getId());
Long brandId = reqVO.getId();
// 校验品牌是否存在
validateBrandExistes(brandId);
List<MachineTemplateDO> machineTemplateDOS = machineTemplateMapper.selectByBrand(brandId);
if (!machineTemplateDOS.isEmpty()) {
// throw exception(MACHINE_TEMPLATE_NOT_EXISTS);
@@ -160,7 +165,7 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
}
machineBrandMapper.deleteById(reqVO.getId());
machineBrandMapper.deleteById(brandId);
return Boolean.TRUE;
}
@@ -281,8 +286,8 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
public void updateMachineTemplateBrand(MachineTemplateBrandReqVO reqVO) {
// MachineBrandDO machineBrandDO = machineBrandMapper.selectBrand(reqVO.getBrand(), reqVO.getMachineType());
MachineBrandDO machineBrandDO = machineBrandMapper.selectById(reqVO.getId());
// 校验机台品牌是否存在
MachineBrandDO machineBrandDO = validateBrandExistes(reqVO.getId());
machineBrandDO.setBrand(reqVO.getBrand());
@@ -291,6 +296,21 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
}
/**
* 校验机台品牌是否存在
*
* @param id
*/
private MachineBrandDO validateBrandExistes(Long id) {
MachineBrandDO machineBrandDO = machineBrandMapper.selectById(id);
if (ObjectUtil.isNull(machineBrandDO)) {
throw exception(THE_CURRENT_BRAND);
}
return machineBrandDO;
}
@Override
public TemplateAutoResp getTemplateAuth(Long organId) {
@@ -60,9 +60,6 @@ public class SmsCodeServiceImpl implements SmsCodeService {
public void sendSmsCode(SmsCodeSendReqDTO reqDTO) {
AdminUserDO user = userService.getUserByUsernameAndOrganId(reqDTO.getMobile(), null);
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
}
// 更新手机号场景检查
if (ObjectUtil.equal(SmsSceneEnum.USER_UPDATE_MOBILE.getScene(), reqDTO.getScene())) {
userUpdateMobileValid(user, loginUser);
@@ -89,6 +86,9 @@ public class SmsCodeServiceImpl implements SmsCodeService {
* @param loginUser
*/
private void userUpdateMobileValid(AdminUserDO user, LoginUser loginUser) {
if (ObjectUtil.isNull(loginUser)) {
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
}
if (ObjectUtil.isNotNull(user)) {
if (ObjectUtil.equal(user.getId(), loginUser.getId())) {
// 手机号没有改变无需验证码
@@ -0,0 +1,32 @@
package com.cf.imes.module.system.validation.machine;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 机台类型校验注解
*
* @author Gqr
* @since 2024/10/16 10:20
*/
@Target({
ElementType.PARAMETER,
ElementType.FIELD,
})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(
validatedBy = {MachineTypeValidator.class}
)
public @interface MachineTypeValid {
String message() default "机台类型类型不合法";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -0,0 +1,28 @@
package com.cf.imes.module.system.validation.machine;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.enums.MachineTypeEnum;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 机台类型校验器
*
* @author Gqr
* @since 2024/10/16 10:21
*/
public class MachineTypeValidator implements ConstraintValidator<MachineTypeValid, Integer> {
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
if (ObjectUtil.isNull(value)) {
return true;
}
for (MachineTypeEnum typeEnum : MachineTypeEnum.values()) {
if (ObjectUtil.equal(typeEnum.getType(), value)) {
return true;
}
}
return false;
}
}