Commit be3b3ef11420a7c49f42865c7c774e995e417678
1 parent
b92c8e1a
feat(mes): 添加安灯配置编号和用户信息字段,重构相关数据对象和服务接口
Showing
12 changed files
with
125 additions
and
30 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/andon/vo/record/MesProAndonRecordPageReqVO.java
| ... | ... | @@ -20,8 +20,11 @@ public class MesProAndonRecordPageReqVO extends PageParam { |
| 20 | 20 | @Schema(description = "工作站编号", example = "100") |
| 21 | 21 | private Long workstationId; |
| 22 | 22 | |
| 23 | - @Schema(description = "级别", example = "1") | |
| 24 | - private Integer level; | |
| 23 | + @Schema(description = "发起用户编号", example = "1") | |
| 24 | + private Long userId; | |
| 25 | + | |
| 26 | + @Schema(description = "处置人编号", example = "1") | |
| 27 | + private Long handlerUserId; | |
| 25 | 28 | |
| 26 | 29 | @Schema(description = "处置状态", example = "0") |
| 27 | 30 | private Integer status; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/andon/vo/record/MesProAndonRecordRespVO.java
| ... | ... | @@ -19,6 +19,9 @@ public class MesProAndonRecordRespVO { |
| 19 | 19 | @ExcelProperty("编号") |
| 20 | 20 | private Long id; |
| 21 | 21 | |
| 22 | + @Schema(description = "安灯配置编号", example = "1") | |
| 23 | + private Long configId; | |
| 24 | + | |
| 22 | 25 | @Schema(description = "工作站编号", example = "100") |
| 23 | 26 | private Long workstationId; |
| 24 | 27 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/andon/vo/record/MesProAndonRecordSaveReqVO.java
| ... | ... | @@ -9,6 +9,10 @@ import lombok.Data; |
| 9 | 9 | @Data |
| 10 | 10 | public class MesProAndonRecordSaveReqVO { |
| 11 | 11 | |
| 12 | + @Schema(description = "安灯配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 13 | + @NotNull(message = "安灯配置不能为空") | |
| 14 | + private Long configId; | |
| 15 | + | |
| 12 | 16 | @Schema(description = "工作站编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| 13 | 17 | @NotNull(message = "工作站不能为空") |
| 14 | 18 | private Long workstationId; |
| ... | ... | @@ -23,14 +27,6 @@ public class MesProAndonRecordSaveReqVO { |
| 23 | 27 | @Schema(description = "工序编号", example = "300") |
| 24 | 28 | private Long processId; |
| 25 | 29 | |
| 26 | - @Schema(description = "呼叫原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "设备故障") | |
| 27 | - @NotEmpty(message = "呼叫原因不能为空") | |
| 28 | - private String reason; | |
| 29 | - | |
| 30 | - @Schema(description = "级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 31 | - @NotNull(message = "级别不能为空") | |
| 32 | - private Integer level; | |
| 33 | - | |
| 34 | 30 | @Schema(description = "备注", example = "备注") |
| 35 | 31 | private String remark; |
| 36 | 32 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/pro/andon/MesProAndonRecordDO.java
| ... | ... | @@ -34,6 +34,12 @@ public class MesProAndonRecordDO extends BaseDO { |
| 34 | 34 | @TableId |
| 35 | 35 | private Long id; |
| 36 | 36 | /** |
| 37 | + * 安灯配置编号 | |
| 38 | + * | |
| 39 | + * 关联 {@link MesProAndonConfigDO#getId()} | |
| 40 | + */ | |
| 41 | + private Long configId; | |
| 42 | + /** | |
| 37 | 43 | * 工作站编号 |
| 38 | 44 | * |
| 39 | 45 | * 关联 {@link MesMdWorkstationDO#getId()} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/andon/MesProAndonConfigMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.pro.andon; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.andon.vo.config.MesProAndonConfigPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.andon.MesProAndonConfigDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * MES 安灯呼叫配置 Mapper | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface MesProAndonConfigMapper extends BaseMapperX<MesProAndonConfigDO> { | |
| 17 | + | |
| 18 | + default PageResult<MesProAndonConfigDO> selectPage(MesProAndonConfigPageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesProAndonConfigDO>() | |
| 20 | + .likeIfPresent(MesProAndonConfigDO::getReason, reqVO.getReason()) | |
| 21 | + .eqIfPresent(MesProAndonConfigDO::getLevel, reqVO.getLevel()) | |
| 22 | + .orderByDesc(MesProAndonConfigDO::getId)); | |
| 23 | + } | |
| 24 | + | |
| 25 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/andon/MesProAndonRecordMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.pro.andon; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.andon.vo.record.MesProAndonRecordPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.andon.MesProAndonRecordDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * MES 安灯呼叫记录 Mapper | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface MesProAndonRecordMapper extends BaseMapperX<MesProAndonRecordDO> { | |
| 17 | + | |
| 18 | + default PageResult<MesProAndonRecordDO> selectPage(MesProAndonRecordPageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesProAndonRecordDO>() | |
| 20 | + .eqIfPresent(MesProAndonRecordDO::getWorkstationId, reqVO.getWorkstationId()) | |
| 21 | + .eqIfPresent(MesProAndonRecordDO::getUserId, reqVO.getUserId()) | |
| 22 | + .eqIfPresent(MesProAndonRecordDO::getHandlerUserId, reqVO.getHandlerUserId()) | |
| 23 | + .eqIfPresent(MesProAndonRecordDO::getStatus, reqVO.getStatus()) | |
| 24 | + .betweenIfPresent(MesProAndonRecordDO::getCreateTime, reqVO.getCreateTime()) | |
| 25 | + .orderByDesc(MesProAndonRecordDO::getId)); | |
| 26 | + } | |
| 27 | + | |
| 28 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationService.java
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationServiceImpl.java
| ... | ... | @@ -108,7 +108,8 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { |
| 108 | 108 | workstationMapper.deleteById(id); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - private void validateWorkstationExists(Long id) { | |
| 111 | + @Override | |
| 112 | + public void validateWorkstationExists(Long id) { | |
| 112 | 113 | if (workstationMapper.selectById(id) == null) { |
| 113 | 114 | throw exception(MD_WORKSTATION_NOT_EXISTS); |
| 114 | 115 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/andon/MesProAndonConfigService.java
| ... | ... | @@ -38,6 +38,14 @@ public interface MesProAndonConfigService { |
| 38 | 38 | void deleteAndonConfig(Long id); |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | + * 校验安灯呼叫配置存在 | |
| 42 | + * | |
| 43 | + * @param id 编号 | |
| 44 | + * @return 安灯呼叫配置 | |
| 45 | + */ | |
| 46 | + MesProAndonConfigDO validateAndonConfigExists(Long id); | |
| 47 | + | |
| 48 | + /** | |
| 41 | 49 | * 获得安灯呼叫配置 |
| 42 | 50 | * |
| 43 | 51 | * @param id 编号 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/andon/MesProAndonConfigServiceImpl.java
| ... | ... | @@ -57,10 +57,13 @@ public class MesProAndonConfigServiceImpl implements MesProAndonConfigService { |
| 57 | 57 | andonConfigMapper.deleteById(id); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - private void validateAndonConfigExists(Long id) { | |
| 61 | - if (andonConfigMapper.selectById(id) == null) { | |
| 60 | + @Override | |
| 61 | + public MesProAndonConfigDO validateAndonConfigExists(Long id) { | |
| 62 | + MesProAndonConfigDO config = andonConfigMapper.selectById(id); | |
| 63 | + if (config == null) { | |
| 62 | 64 | throw exception(PRO_ANDON_CONFIG_NOT_EXISTS); |
| 63 | 65 | } |
| 66 | + return config; | |
| 64 | 67 | } |
| 65 | 68 | |
| 66 | 69 | @Override | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/andon/MesProAndonRecordServiceImpl.java
| ... | ... | @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | 6 | import cn.iocoder.yudao.module.mes.controller.admin.pro.andon.vo.record.MesProAndonRecordHandleReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.mes.controller.admin.pro.andon.vo.record.MesProAndonRecordPageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.mes.controller.admin.pro.andon.vo.record.MesProAndonRecordSaveReqVO; |
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.andon.MesProAndonConfigDO; | |
| 9 | 10 | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.andon.MesProAndonRecordDO; |
| 10 | 11 | import cn.iocoder.yudao.module.mes.dal.mysql.pro.andon.MesProAndonRecordMapper; |
| 11 | 12 | import cn.iocoder.yudao.module.mes.enums.pro.MesProAndonStatusEnum; |
| ... | ... | @@ -17,8 +18,7 @@ import org.springframework.stereotype.Service; |
| 17 | 18 | import org.springframework.validation.annotation.Validated; |
| 18 | 19 | |
| 19 | 20 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 20 | -import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_ANDON_RECORD_ALREADY_HANDLED; | |
| 21 | -import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_ANDON_RECORD_NOT_EXISTS; | |
| 21 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * MES 安灯呼叫记录 Service 实现类 |
| ... | ... | @@ -41,19 +41,24 @@ public class MesProAndonRecordServiceImpl implements MesProAndonRecordService { |
| 41 | 41 | @Resource |
| 42 | 42 | private MesProProcessService processService; |
| 43 | 43 | |
| 44 | + @Resource | |
| 45 | + private MesProAndonConfigService andonConfigService; | |
| 46 | + | |
| 44 | 47 | @Override |
| 45 | 48 | public Long createAndonRecord(MesProAndonRecordSaveReqVO createReqVO) { |
| 46 | 49 | // 1. 校验关联数据存在 |
| 47 | - workstationService.getWorkstation(createReqVO.getWorkstationId()); // 工作站必填,直接校验 | |
| 50 | + MesProAndonConfigDO config = andonConfigService.validateAndonConfigExists(createReqVO.getConfigId()); | |
| 51 | + workstationService.validateWorkstationExists(createReqVO.getWorkstationId()); | |
| 48 | 52 | if (createReqVO.getWorkOrderId() != null) { |
| 49 | 53 | workOrderService.validateWorkOrderExists(createReqVO.getWorkOrderId()); |
| 50 | 54 | } |
| 51 | 55 | if (createReqVO.getProcessId() != null) { |
| 52 | - processService.getProcess(createReqVO.getProcessId()); | |
| 56 | + processService.validateProcessExists(createReqVO.getProcessId()); | |
| 53 | 57 | } |
| 54 | 58 | |
| 55 | 59 | // 2. 插入 |
| 56 | 60 | MesProAndonRecordDO record = BeanUtils.toBean(createReqVO, MesProAndonRecordDO.class); |
| 61 | + record.setReason(config.getReason()).setLevel(config.getLevel()); | |
| 57 | 62 | record.setStatus(MesProAndonStatusEnum.ACTIVE.getStatus()); |
| 58 | 63 | andonRecordMapper.insert(record); |
| 59 | 64 | return record.getId(); | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.service.pro.process; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | 6 | import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO; |
| ... | ... | @@ -12,6 +13,7 @@ import org.springframework.stereotype.Service; |
| 12 | 13 | import org.springframework.transaction.annotation.Transactional; |
| 13 | 14 | import org.springframework.validation.annotation.Validated; |
| 14 | 15 | |
| 16 | +import java.util.Collections; | |
| 15 | 17 | import java.util.List; |
| 16 | 18 | |
| 17 | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -37,11 +39,12 @@ public class MesProProcessServiceImpl implements MesProProcessService { |
| 37 | 39 | |
| 38 | 40 | @Override |
| 39 | 41 | public Long createProcess(MesProProcessSaveReqVO createReqVO) { |
| 40 | - // 1. 校验工序编码唯一性 | |
| 42 | + // 1.1 校验工序编码唯一性 | |
| 41 | 43 | validateProcessCodeUnique(null, createReqVO.getCode()); |
| 42 | - // 2. 校验工序名称唯一性 | |
| 44 | + // 1.2 校验工序名称唯一性 | |
| 43 | 45 | validateProcessNameUnique(null, createReqVO.getName()); |
| 44 | - // 3. 插入工序 | |
| 46 | + | |
| 47 | + // 2. 插入工序 | |
| 45 | 48 | MesProProcessDO process = BeanUtils.toBean(createReqVO, MesProProcessDO.class); |
| 46 | 49 | processMapper.insert(process); |
| 47 | 50 | return process.getId(); |
| ... | ... | @@ -49,13 +52,14 @@ public class MesProProcessServiceImpl implements MesProProcessService { |
| 49 | 52 | |
| 50 | 53 | @Override |
| 51 | 54 | public void updateProcess(MesProProcessSaveReqVO updateReqVO) { |
| 52 | - // 1. 校验存在 | |
| 55 | + // 1.1 校验存在 | |
| 53 | 56 | validateProcessExists(updateReqVO.getId()); |
| 54 | - // 2. 校验工序编码唯一性 | |
| 57 | + // 1.2 校验工序编码唯一性 | |
| 55 | 58 | validateProcessCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); |
| 56 | - // 3. 校验工序名称唯一性 | |
| 59 | + // 1.3 校验工序名称唯一性 | |
| 57 | 60 | validateProcessNameUnique(updateReqVO.getId(), updateReqVO.getName()); |
| 58 | - // 4. 更新工序 | |
| 61 | + | |
| 62 | + // 2. 更新工序 | |
| 59 | 63 | MesProProcessDO updateObj = BeanUtils.toBean(updateReqVO, MesProProcessDO.class); |
| 60 | 64 | processMapper.updateById(updateObj); |
| 61 | 65 | } |
| ... | ... | @@ -63,19 +67,22 @@ public class MesProProcessServiceImpl implements MesProProcessService { |
| 63 | 67 | @Override |
| 64 | 68 | @Transactional(rollbackFor = Exception.class) |
| 65 | 69 | public void deleteProcess(Long id) { |
| 66 | - // 1. 校验存在 | |
| 70 | + // 1.1 校验存在 | |
| 67 | 71 | validateProcessExists(id); |
| 68 | - // 2. 校验是否被工艺路线引用 | |
| 72 | + // 1.2 校验是否被工艺路线引用 | |
| 73 | + // TODO @AI:CollUtil.isNotEmpty() 可能更好 | |
| 69 | 74 | if (!routeProcessMapper.selectListByProcessId(id).isEmpty()) { |
| 70 | 75 | throw exception(PRO_PROCESS_USED_BY_ROUTE); |
| 71 | 76 | } |
| 72 | - // 3. 删除工序 | |
| 77 | + | |
| 78 | + // 2. 删除工序 | |
| 73 | 79 | processMapper.deleteById(id); |
| 74 | - // 4. 级联删除工序内容 | |
| 80 | + // 3. 级联删除工序内容 | |
| 75 | 81 | processContentService.deleteProcessContentByProcessId(id); |
| 76 | 82 | } |
| 77 | 83 | |
| 78 | - private void validateProcessExists(Long id) { | |
| 84 | + @Override | |
| 85 | + public void validateProcessExists(Long id) { | |
| 79 | 86 | if (processMapper.selectById(id) == null) { |
| 80 | 87 | throw exception(PRO_PROCESS_NOT_EXISTS); |
| 81 | 88 | } |
| ... | ... | @@ -114,7 +121,10 @@ public class MesProProcessServiceImpl implements MesProProcessService { |
| 114 | 121 | |
| 115 | 122 | @Override |
| 116 | 123 | public List<MesProProcessDO> getProcessList(List<Long> ids) { |
| 117 | - return processMapper.selectBatchIds(ids); | |
| 124 | + if (CollUtil.isEmpty(ids)) { | |
| 125 | + return Collections.emptyList(); | |
| 126 | + } | |
| 127 | + return processMapper.selectByIds(ids); | |
| 118 | 128 | } |
| 119 | 129 | |
| 120 | 130 | @Override | ... | ... |