Commit 71ef24a25844527f7bfe5278a8b897f014967260
1 parent
3ca2f75f
✨ feat(mes): 添加工作站设备资源的级联删除功能
新增按工作站编号删除设备资源的功能,确保在删除工作站时,相关的设备资源能够被自动清理,提升数据一致性和管理效率。
Showing
15 changed files
with
145 additions
and
59 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
| @@ -79,7 +79,7 @@ public interface ErrorCodeConstants { | @@ -79,7 +79,7 @@ public interface ErrorCodeConstants { | ||
| 79 | ErrorCode MD_WORKSTATION_NAME_DUPLICATE = new ErrorCode(1_040_106_002, "工作站名称已存在"); | 79 | ErrorCode MD_WORKSTATION_NAME_DUPLICATE = new ErrorCode(1_040_106_002, "工作站名称已存在"); |
| 80 | // ========== MES 基础数据-设备资源(1-040-106-100) ========== | 80 | // ========== MES 基础数据-设备资源(1-040-106-100) ========== |
| 81 | ErrorCode MD_WORKSTATION_MACHINE_NOT_EXISTS = new ErrorCode(1_040_106_100, "设备资源记录不存在"); | 81 | ErrorCode MD_WORKSTATION_MACHINE_NOT_EXISTS = new ErrorCode(1_040_106_100, "设备资源记录不存在"); |
| 82 | - ErrorCode MD_WORKSTATION_MACHINE_EXISTS = new ErrorCode(1_040_106_101, "该设备已分配到其他工作站"); | 82 | + ErrorCode MD_WORKSTATION_MACHINE_EXISTS = new ErrorCode(1_040_106_101, "该设备已分配至工作站:{}"); |
| 83 | // ========== MES 基础数据-工装夹具资源(1-040-106-200) ========== | 83 | // ========== MES 基础数据-工装夹具资源(1-040-106-200) ========== |
| 84 | ErrorCode MD_WORKSTATION_TOOL_NOT_EXISTS = new ErrorCode(1_040_106_200, "工装夹具资源记录不存在"); | 84 | ErrorCode MD_WORKSTATION_TOOL_NOT_EXISTS = new ErrorCode(1_040_106_200, "工装夹具资源记录不存在"); |
| 85 | ErrorCode MD_WORKSTATION_TOOL_TYPE_EXISTS = new ErrorCode(1_040_106_201, "该工具类型已在此工作站中存在"); | 85 | ErrorCode MD_WORKSTATION_TOOL_TYPE_EXISTS = new ErrorCode(1_040_106_201, "该工具类型已在此工作站中存在"); |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationMachineService.java
| @@ -36,4 +36,11 @@ public interface MesMdWorkstationMachineService { | @@ -36,4 +36,11 @@ public interface MesMdWorkstationMachineService { | ||
| 36 | */ | 36 | */ |
| 37 | List<MesMdWorkstationMachineDO> getWorkstationMachineListByWorkstationId(Long workstationId); | 37 | List<MesMdWorkstationMachineDO> getWorkstationMachineListByWorkstationId(Long workstationId); |
| 38 | 38 | ||
| 39 | + /** | ||
| 40 | + * 按工作站编号删除设备资源(级联删除) | ||
| 41 | + * | ||
| 42 | + * @param workstationId 工作站编号 | ||
| 43 | + */ | ||
| 44 | + void deleteWorkstationMachineByWorkstationId(Long workstationId); | ||
| 45 | + | ||
| 39 | } | 46 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationMachineServiceImpl.java
| @@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.mes.service.md.workstation; | @@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.mes.service.md.workstation; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 3 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 4 | import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.machine.MesMdWorkstationMachineSaveReqVO; | 4 | import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.machine.MesMdWorkstationMachineSaveReqVO; |
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; | ||
| 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationMachineDO; | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationMachineDO; |
| 6 | import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationMachineMapper; | 7 | import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationMachineMapper; |
| 8 | +import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationMapper; | ||
| 9 | +import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; | ||
| 7 | import jakarta.annotation.Resource; | 10 | import jakarta.annotation.Resource; |
| 8 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 9 | import org.springframework.validation.annotation.Validated; | 12 | import org.springframework.validation.annotation.Validated; |
| @@ -25,13 +28,16 @@ public class MesMdWorkstationMachineServiceImpl implements MesMdWorkstationMachi | @@ -25,13 +28,16 @@ public class MesMdWorkstationMachineServiceImpl implements MesMdWorkstationMachi | ||
| 25 | @Resource | 28 | @Resource |
| 26 | private MesMdWorkstationMachineMapper workstationMachineMapper; | 29 | private MesMdWorkstationMachineMapper workstationMachineMapper; |
| 27 | 30 | ||
| 31 | + @Resource | ||
| 32 | + private MesMdWorkstationMapper workstationMapper; | ||
| 33 | + | ||
| 34 | + @Resource | ||
| 35 | + private MesDvMachineryService machineryService; | ||
| 36 | + | ||
| 28 | @Override | 37 | @Override |
| 29 | public Long createWorkstationMachine(MesMdWorkstationMachineSaveReqVO createReqVO) { | 38 | public Long createWorkstationMachine(MesMdWorkstationMachineSaveReqVO createReqVO) { |
| 30 | - // 校验该设备是否已分配到其他工作站 | ||
| 31 | - MesMdWorkstationMachineDO existing = workstationMachineMapper.selectByMachineryId(createReqVO.getMachineryId()); | ||
| 32 | - if (existing != null) { | ||
| 33 | - throw exception(MD_WORKSTATION_MACHINE_EXISTS); | ||
| 34 | - } | 39 | + // 校验数据 |
| 40 | + validateWorkstationMachineSaveData(createReqVO); | ||
| 35 | 41 | ||
| 36 | // 插入 | 42 | // 插入 |
| 37 | MesMdWorkstationMachineDO machine = BeanUtils.toBean(createReqVO, MesMdWorkstationMachineDO.class); | 43 | MesMdWorkstationMachineDO machine = BeanUtils.toBean(createReqVO, MesMdWorkstationMachineDO.class); |
| @@ -39,6 +45,18 @@ public class MesMdWorkstationMachineServiceImpl implements MesMdWorkstationMachi | @@ -39,6 +45,18 @@ public class MesMdWorkstationMachineServiceImpl implements MesMdWorkstationMachi | ||
| 39 | return machine.getId(); | 45 | return machine.getId(); |
| 40 | } | 46 | } |
| 41 | 47 | ||
| 48 | + private void validateWorkstationMachineSaveData(MesMdWorkstationMachineSaveReqVO reqVO) { | ||
| 49 | + // 校验设备是否存在 | ||
| 50 | + machineryService.validateMachineryExists(reqVO.getMachineryId()); | ||
| 51 | + // 校验该设备是否已分配到其他工作站(一台设备只能分配到一个工作站) | ||
| 52 | + MesMdWorkstationMachineDO existing = workstationMachineMapper.selectByMachineryId(reqVO.getMachineryId()); | ||
| 53 | + if (existing != null) { | ||
| 54 | + MesMdWorkstationDO workstation = workstationMapper.selectById(existing.getWorkstationId()); | ||
| 55 | + throw exception(MD_WORKSTATION_MACHINE_EXISTS, | ||
| 56 | + workstation != null ? workstation.getName() : String.valueOf(existing.getWorkstationId())); | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 42 | @Override | 60 | @Override |
| 43 | public void deleteWorkstationMachine(Long id) { | 61 | public void deleteWorkstationMachine(Long id) { |
| 44 | if (workstationMachineMapper.selectById(id) == null) { | 62 | if (workstationMachineMapper.selectById(id) == null) { |
| @@ -52,4 +70,9 @@ public class MesMdWorkstationMachineServiceImpl implements MesMdWorkstationMachi | @@ -52,4 +70,9 @@ public class MesMdWorkstationMachineServiceImpl implements MesMdWorkstationMachi | ||
| 52 | return workstationMachineMapper.selectListByWorkstationId(workstationId); | 70 | return workstationMachineMapper.selectListByWorkstationId(workstationId); |
| 53 | } | 71 | } |
| 54 | 72 | ||
| 73 | + @Override | ||
| 74 | + public void deleteWorkstationMachineByWorkstationId(Long workstationId) { | ||
| 75 | + workstationMachineMapper.deleteByWorkstationId(workstationId); | ||
| 76 | + } | ||
| 77 | + | ||
| 55 | } | 78 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationServiceImpl.java
| @@ -9,11 +9,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.MesMdWorks | @@ -9,11 +9,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.MesMdWorks | ||
| 9 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkshopDO; | 9 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkshopDO; |
| 10 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; | 10 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; |
| 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO; | 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO; |
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseDO; | ||
| 12 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseLocationDO; | 13 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseLocationDO; |
| 13 | -import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationMachineMapper; | ||
| 14 | import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationMapper; | 14 | import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationMapper; |
| 15 | -import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationToolMapper; | ||
| 16 | -import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationWorkerMapper; | ||
| 17 | import cn.iocoder.yudao.module.mes.enums.wm.BarcodeBizTypeEnum; | 15 | import cn.iocoder.yudao.module.mes.enums.wm.BarcodeBizTypeEnum; |
| 18 | import cn.iocoder.yudao.module.mes.service.wm.barcode.MesWmBarcodeService; | 16 | import cn.iocoder.yudao.module.mes.service.wm.barcode.MesWmBarcodeService; |
| 19 | import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService; | 17 | import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService; |
| @@ -45,29 +43,22 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | @@ -45,29 +43,22 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | ||
| 45 | private MesMdWorkstationMapper workstationMapper; | 43 | private MesMdWorkstationMapper workstationMapper; |
| 46 | 44 | ||
| 47 | @Resource | 45 | @Resource |
| 48 | - private MesMdWorkstationMachineMapper workstationMachineMapper; | ||
| 49 | - | 46 | + private MesMdWorkstationMachineService workstationMachineService; |
| 50 | @Resource | 47 | @Resource |
| 51 | - private MesMdWorkstationToolMapper workstationToolMapper; | ||
| 52 | - | 48 | + private MesMdWorkstationToolService workstationToolService; |
| 53 | @Resource | 49 | @Resource |
| 54 | - private MesMdWorkstationWorkerMapper workstationWorkerMapper; | 50 | + private MesMdWorkstationWorkerService workstationWorkerService; |
| 55 | 51 | ||
| 56 | @Resource | 52 | @Resource |
| 57 | private MesMdWorkshopService workshopService; | 53 | private MesMdWorkshopService workshopService; |
| 58 | - | ||
| 59 | @Resource | 54 | @Resource |
| 60 | private MesWmWarehouseService warehouseService; | 55 | private MesWmWarehouseService warehouseService; |
| 61 | - | ||
| 62 | @Resource | 56 | @Resource |
| 63 | private MesWmWarehouseLocationService locationService; | 57 | private MesWmWarehouseLocationService locationService; |
| 64 | - | ||
| 65 | @Resource | 58 | @Resource |
| 66 | private MesWmWarehouseAreaService areaService; | 59 | private MesWmWarehouseAreaService areaService; |
| 67 | - | ||
| 68 | @Resource | 60 | @Resource |
| 69 | private MesWmBarcodeService barcodeService; | 61 | private MesWmBarcodeService barcodeService; |
| 70 | - | ||
| 71 | @Resource | 62 | @Resource |
| 72 | private MesProProcessService processService; | 63 | private MesProProcessService processService; |
| 73 | 64 | ||
| @@ -107,8 +98,8 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | @@ -107,8 +98,8 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | ||
| 107 | validateWorkshopExists(reqVO.getWorkshopId()); | 98 | validateWorkshopExists(reqVO.getWorkshopId()); |
| 108 | // 校验工序存在 | 99 | // 校验工序存在 |
| 109 | processService.validateProcessExists(reqVO.getProcessId()); | 100 | processService.validateProcessExists(reqVO.getProcessId()); |
| 110 | - // 校验仓库层级 | ||
| 111 | - validateWarehouseHierarchy(reqVO); | 101 | + // 处理仓库层级(未指定仓库时自动设置虚拟线边库) |
| 102 | + handleWarehouseHierarchy(reqVO); | ||
| 112 | } | 103 | } |
| 113 | 104 | ||
| 114 | @Override | 105 | @Override |
| @@ -118,9 +109,9 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | @@ -118,9 +109,9 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | ||
| 118 | validateWorkstationExists(id); | 109 | validateWorkstationExists(id); |
| 119 | 110 | ||
| 120 | // 级联删除子资源 | 111 | // 级联删除子资源 |
| 121 | - workstationMachineMapper.deleteByWorkstationId(id); | ||
| 122 | - workstationToolMapper.deleteByWorkstationId(id); | ||
| 123 | - workstationWorkerMapper.deleteByWorkstationId(id); | 112 | + workstationMachineService.deleteWorkstationMachineByWorkstationId(id); |
| 113 | + workstationToolService.deleteWorkstationToolByWorkstationId(id); | ||
| 114 | + workstationWorkerService.deleteWorkstationWorkerByWorkstationId(id); | ||
| 124 | // 删除工作站 | 115 | // 删除工作站 |
| 125 | workstationMapper.deleteById(id); | 116 | workstationMapper.deleteById(id); |
| 126 | } | 117 | } |
| @@ -142,22 +133,31 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | @@ -142,22 +133,31 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | ||
| 142 | } | 133 | } |
| 143 | 134 | ||
| 144 | /** | 135 | /** |
| 145 | - * 校验仓库层级关系 | 136 | + * 校验并处理仓库层级关系 |
| 146 | * | 137 | * |
| 147 | - * 仓库层级结构:仓库 -> 库位 -> 库区 | ||
| 148 | - * 校验规则: | ||
| 149 | - * 1. 如果填写了库位,必须填写仓库,且库位必须属于该仓库 | ||
| 150 | - * 2. 如果填写了库区,必须填写库位,且库区必须属于该库位 | 138 | + * 仓库层级结构:仓库 -> 库区 -> 库位 |
| 139 | + * 处理规则: | ||
| 140 | + * 1. 如果仓库/库区/库位都未填写,则自动设置虚拟线边库 | ||
| 141 | + * 2. 如果填写了库区,必须填写仓库,且库区必须属于该仓库 | ||
| 142 | + * 3. 如果填写了库位,必须填写库区,且库位必须属于该库区 | ||
| 151 | * | 143 | * |
| 152 | * @param reqVO 工作站保存请求对象 | 144 | * @param reqVO 工作站保存请求对象 |
| 153 | */ | 145 | */ |
| 154 | - private void validateWarehouseHierarchy(MesMdWorkstationSaveReqVO reqVO) { | ||
| 155 | - // 1.1 获取仓库、库位、库区 ID | 146 | + private void handleWarehouseHierarchy(MesMdWorkstationSaveReqVO reqVO) { |
| 147 | + // 1.1 获取仓库、库区、库位 ID | ||
| 156 | Long warehouseId = reqVO.getWarehouseId(); | 148 | Long warehouseId = reqVO.getWarehouseId(); |
| 157 | Long locationId = reqVO.getLocationId(); | 149 | Long locationId = reqVO.getLocationId(); |
| 158 | Long areaId = reqVO.getAreaId(); | 150 | Long areaId = reqVO.getAreaId(); |
| 159 | - // 1.2 如果都为空,则无需校验 | 151 | + // 1.2 如果都为空,则自动设置虚拟线边库 |
| 160 | if (warehouseId == null && locationId == null && areaId == null) { | 152 | if (warehouseId == null && locationId == null && areaId == null) { |
| 153 | + MesWmWarehouseDO warehouse = warehouseService.getWarehouseByCode(MesWmWarehouseDO.WIP_VIRTUAL_WAREHOUSE); | ||
| 154 | + MesWmWarehouseLocationDO location = locationService.getWarehouseLocationByCode( | ||
| 155 | + MesWmWarehouseLocationDO.WIP_VIRTUAL_LOCATION); | ||
| 156 | + MesWmWarehouseAreaDO area = areaService.getWarehouseAreaByCode( | ||
| 157 | + MesWmWarehouseAreaDO.WIP_VIRTUAL_AREA); | ||
| 158 | + reqVO.setWarehouseId(warehouse.getId()); | ||
| 159 | + reqVO.setLocationId(location.getId()); | ||
| 160 | + reqVO.setAreaId(area.getId()); | ||
| 161 | return; | 161 | return; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| @@ -166,32 +166,32 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | @@ -166,32 +166,32 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | ||
| 166 | warehouseService.validateWarehouseExists(warehouseId); | 166 | warehouseService.validateWarehouseExists(warehouseId); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | - // 3. 校验库位:如果填写了库位,必须填写仓库,且库位必须属于该仓库 | 169 | + // 3. 校验库区:如果填写了库区,必须填写仓库,且库区必须属于该仓库 |
| 170 | MesWmWarehouseLocationDO location; | 170 | MesWmWarehouseLocationDO location; |
| 171 | if (locationId != null) { | 171 | if (locationId != null) { |
| 172 | - // 3.1 校验库位是否存在 | 172 | + // 3.1 校验库区是否存在 |
| 173 | location = locationService.validateWarehouseLocationExists(locationId); | 173 | location = locationService.validateWarehouseLocationExists(locationId); |
| 174 | // 3.2 校验必须填写仓库 | 174 | // 3.2 校验必须填写仓库 |
| 175 | if (warehouseId == null) { | 175 | if (warehouseId == null) { |
| 176 | throw exception(WM_WAREHOUSE_REQUIRED); | 176 | throw exception(WM_WAREHOUSE_REQUIRED); |
| 177 | } | 177 | } |
| 178 | - // 3.3 校验库位是否属于该仓库 | 178 | + // 3.3 校验库区是否属于该仓库 |
| 179 | if (ObjUtil.notEqual(location.getWarehouseId(), warehouseId)) { | 179 | if (ObjUtil.notEqual(location.getWarehouseId(), warehouseId)) { |
| 180 | throw exception(WM_WAREHOUSE_LOCATION_RELATION_INVALID); | 180 | throw exception(WM_WAREHOUSE_LOCATION_RELATION_INVALID); |
| 181 | } | 181 | } |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | - // 4. 校验库区:如果填写了库区,必须填写库位,且库区必须属于该库位 | 184 | + // 4. 校验库位:如果填写了库位,必须填写库区,且库位必须属于该库区 |
| 185 | if (areaId == null) { | 185 | if (areaId == null) { |
| 186 | return; | 186 | return; |
| 187 | } | 187 | } |
| 188 | - // 4.1 校验库区是否存在 | 188 | + // 4.1 校验库位是否存在 |
| 189 | MesWmWarehouseAreaDO area = areaService.validateWarehouseAreaExists(areaId); | 189 | MesWmWarehouseAreaDO area = areaService.validateWarehouseAreaExists(areaId); |
| 190 | - // 4.2 校验必须填写库位 | 190 | + // 4.2 校验必须填写库区 |
| 191 | if (locationId == null) { | 191 | if (locationId == null) { |
| 192 | throw exception(WM_WAREHOUSE_LOCATION_REQUIRED); | 192 | throw exception(WM_WAREHOUSE_LOCATION_REQUIRED); |
| 193 | } | 193 | } |
| 194 | - // 4.3 校验库区是否属于该库位 | 194 | + // 4.3 校验库位是否属于该库区 |
| 195 | if (ObjUtil.notEqual(area.getLocationId(), locationId)) { | 195 | if (ObjUtil.notEqual(area.getLocationId(), locationId)) { |
| 196 | throw exception(WM_WAREHOUSE_AREA_RELATION_INVALID); | 196 | throw exception(WM_WAREHOUSE_AREA_RELATION_INVALID); |
| 197 | } | 197 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationToolService.java
| @@ -43,4 +43,11 @@ public interface MesMdWorkstationToolService { | @@ -43,4 +43,11 @@ public interface MesMdWorkstationToolService { | ||
| 43 | */ | 43 | */ |
| 44 | List<MesMdWorkstationToolDO> getWorkstationToolListByWorkstationId(Long workstationId); | 44 | List<MesMdWorkstationToolDO> getWorkstationToolListByWorkstationId(Long workstationId); |
| 45 | 45 | ||
| 46 | + /** | ||
| 47 | + * 按工作站编号删除工装夹具资源(级联删除) | ||
| 48 | + * | ||
| 49 | + * @param workstationId 工作站编号 | ||
| 50 | + */ | ||
| 51 | + void deleteWorkstationToolByWorkstationId(Long workstationId); | ||
| 52 | + | ||
| 46 | } | 53 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationToolServiceImpl.java
| 1 | package cn.iocoder.yudao.module.mes.service.md.workstation; | 1 | package cn.iocoder.yudao.module.mes.service.md.workstation; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.util.ObjUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 4 | import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.tool.MesMdWorkstationToolSaveReqVO; | 5 | import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.tool.MesMdWorkstationToolSaveReqVO; |
| 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationToolDO; | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationToolDO; |
| 6 | import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationToolMapper; | 7 | import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationToolMapper; |
| 8 | +import cn.iocoder.yudao.module.mes.service.tm.tool.MesTmToolTypeService; | ||
| 7 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| 8 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 9 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| @@ -25,14 +27,13 @@ public class MesMdWorkstationToolServiceImpl implements MesMdWorkstationToolServ | @@ -25,14 +27,13 @@ public class MesMdWorkstationToolServiceImpl implements MesMdWorkstationToolServ | ||
| 25 | @Resource | 27 | @Resource |
| 26 | private MesMdWorkstationToolMapper workstationToolMapper; | 28 | private MesMdWorkstationToolMapper workstationToolMapper; |
| 27 | 29 | ||
| 30 | + @Resource | ||
| 31 | + private MesTmToolTypeService toolTypeService; | ||
| 32 | + | ||
| 28 | @Override | 33 | @Override |
| 29 | public Long createWorkstationTool(MesMdWorkstationToolSaveReqVO createReqVO) { | 34 | public Long createWorkstationTool(MesMdWorkstationToolSaveReqVO createReqVO) { |
| 30 | - // 校验同一工作站下工具类型不重复 | ||
| 31 | - MesMdWorkstationToolDO existing = workstationToolMapper.selectByWorkstationIdAndToolTypeId( | ||
| 32 | - createReqVO.getWorkstationId(), createReqVO.getToolTypeId()); | ||
| 33 | - if (existing != null) { | ||
| 34 | - throw exception(MD_WORKSTATION_TOOL_TYPE_EXISTS); | ||
| 35 | - } | 35 | + // 校验数据 |
| 36 | + validateWorkstationToolSaveData(null, createReqVO); | ||
| 36 | 37 | ||
| 37 | // 插入 | 38 | // 插入 |
| 38 | MesMdWorkstationToolDO tool = BeanUtils.toBean(createReqVO, MesMdWorkstationToolDO.class); | 39 | MesMdWorkstationToolDO tool = BeanUtils.toBean(createReqVO, MesMdWorkstationToolDO.class); |
| @@ -44,12 +45,25 @@ public class MesMdWorkstationToolServiceImpl implements MesMdWorkstationToolServ | @@ -44,12 +45,25 @@ public class MesMdWorkstationToolServiceImpl implements MesMdWorkstationToolServ | ||
| 44 | public void updateWorkstationTool(MesMdWorkstationToolSaveReqVO updateReqVO) { | 45 | public void updateWorkstationTool(MesMdWorkstationToolSaveReqVO updateReqVO) { |
| 45 | // 校验存在 | 46 | // 校验存在 |
| 46 | validateWorkstationToolExists(updateReqVO.getId()); | 47 | validateWorkstationToolExists(updateReqVO.getId()); |
| 48 | + // 校验数据 | ||
| 49 | + validateWorkstationToolSaveData(updateReqVO.getId(), updateReqVO); | ||
| 47 | 50 | ||
| 48 | // 更新 | 51 | // 更新 |
| 49 | MesMdWorkstationToolDO updateObj = BeanUtils.toBean(updateReqVO, MesMdWorkstationToolDO.class); | 52 | MesMdWorkstationToolDO updateObj = BeanUtils.toBean(updateReqVO, MesMdWorkstationToolDO.class); |
| 50 | workstationToolMapper.updateById(updateObj); | 53 | workstationToolMapper.updateById(updateObj); |
| 51 | } | 54 | } |
| 52 | 55 | ||
| 56 | + private void validateWorkstationToolSaveData(Long id, MesMdWorkstationToolSaveReqVO reqVO) { | ||
| 57 | + // 校验工具类型是否存在 | ||
| 58 | + toolTypeService.validateToolTypeExists(reqVO.getToolTypeId()); | ||
| 59 | + // 校验同一工作站下工具类型不重复(排除自身) | ||
| 60 | + MesMdWorkstationToolDO existing = workstationToolMapper.selectByWorkstationIdAndToolTypeId( | ||
| 61 | + reqVO.getWorkstationId(), reqVO.getToolTypeId()); | ||
| 62 | + if (existing != null && ObjUtil.notEqual(existing.getId(), id)) { | ||
| 63 | + throw exception(MD_WORKSTATION_TOOL_TYPE_EXISTS); | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + | ||
| 53 | @Override | 67 | @Override |
| 54 | public void deleteWorkstationTool(Long id) { | 68 | public void deleteWorkstationTool(Long id) { |
| 55 | // 校验存在 | 69 | // 校验存在 |
| @@ -70,4 +84,9 @@ public class MesMdWorkstationToolServiceImpl implements MesMdWorkstationToolServ | @@ -70,4 +84,9 @@ public class MesMdWorkstationToolServiceImpl implements MesMdWorkstationToolServ | ||
| 70 | return workstationToolMapper.selectListByWorkstationId(workstationId); | 84 | return workstationToolMapper.selectListByWorkstationId(workstationId); |
| 71 | } | 85 | } |
| 72 | 86 | ||
| 87 | + @Override | ||
| 88 | + public void deleteWorkstationToolByWorkstationId(Long workstationId) { | ||
| 89 | + workstationToolMapper.deleteByWorkstationId(workstationId); | ||
| 90 | + } | ||
| 91 | + | ||
| 73 | } | 92 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationWorkerService.java
| @@ -43,4 +43,11 @@ public interface MesMdWorkstationWorkerService { | @@ -43,4 +43,11 @@ public interface MesMdWorkstationWorkerService { | ||
| 43 | */ | 43 | */ |
| 44 | List<MesMdWorkstationWorkerDO> getWorkstationWorkerListByWorkstationId(Long workstationId); | 44 | List<MesMdWorkstationWorkerDO> getWorkstationWorkerListByWorkstationId(Long workstationId); |
| 45 | 45 | ||
| 46 | + /** | ||
| 47 | + * 按工作站编号删除人力资源(级联删除) | ||
| 48 | + * | ||
| 49 | + * @param workstationId 工作站编号 | ||
| 50 | + */ | ||
| 51 | + void deleteWorkstationWorkerByWorkstationId(Long workstationId); | ||
| 52 | + | ||
| 46 | } | 53 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationWorkerServiceImpl.java
| 1 | package cn.iocoder.yudao.module.mes.service.md.workstation; | 1 | package cn.iocoder.yudao.module.mes.service.md.workstation; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.util.ObjUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 4 | import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.worker.MesMdWorkstationWorkerSaveReqVO; | 5 | import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.worker.MesMdWorkstationWorkerSaveReqVO; |
| 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationWorkerDO; | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationWorkerDO; |
| 6 | import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationWorkerMapper; | 7 | import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationWorkerMapper; |
| 8 | +import cn.iocoder.yudao.module.system.api.dept.PostApi; | ||
| 7 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| 8 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 9 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| 10 | 12 | ||
| 13 | +import java.util.Collections; | ||
| 11 | import java.util.List; | 14 | import java.util.List; |
| 12 | 15 | ||
| 13 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 16 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -25,14 +28,13 @@ public class MesMdWorkstationWorkerServiceImpl implements MesMdWorkstationWorker | @@ -25,14 +28,13 @@ public class MesMdWorkstationWorkerServiceImpl implements MesMdWorkstationWorker | ||
| 25 | @Resource | 28 | @Resource |
| 26 | private MesMdWorkstationWorkerMapper workstationWorkerMapper; | 29 | private MesMdWorkstationWorkerMapper workstationWorkerMapper; |
| 27 | 30 | ||
| 31 | + @Resource | ||
| 32 | + private PostApi postApi; | ||
| 33 | + | ||
| 28 | @Override | 34 | @Override |
| 29 | public Long createWorkstationWorker(MesMdWorkstationWorkerSaveReqVO createReqVO) { | 35 | public Long createWorkstationWorker(MesMdWorkstationWorkerSaveReqVO createReqVO) { |
| 30 | - // 校验同一工作站下岗位不重复 | ||
| 31 | - MesMdWorkstationWorkerDO existing = workstationWorkerMapper.selectByWorkstationIdAndPostId( | ||
| 32 | - createReqVO.getWorkstationId(), createReqVO.getPostId()); | ||
| 33 | - if (existing != null) { | ||
| 34 | - throw exception(MD_WORKSTATION_WORKER_POST_EXISTS); | ||
| 35 | - } | 36 | + // 校验数据 |
| 37 | + validateWorkstationWorkerSaveData(null, createReqVO); | ||
| 36 | 38 | ||
| 37 | // 插入 | 39 | // 插入 |
| 38 | MesMdWorkstationWorkerDO worker = BeanUtils.toBean(createReqVO, MesMdWorkstationWorkerDO.class); | 40 | MesMdWorkstationWorkerDO worker = BeanUtils.toBean(createReqVO, MesMdWorkstationWorkerDO.class); |
| @@ -44,12 +46,25 @@ public class MesMdWorkstationWorkerServiceImpl implements MesMdWorkstationWorker | @@ -44,12 +46,25 @@ public class MesMdWorkstationWorkerServiceImpl implements MesMdWorkstationWorker | ||
| 44 | public void updateWorkstationWorker(MesMdWorkstationWorkerSaveReqVO updateReqVO) { | 46 | public void updateWorkstationWorker(MesMdWorkstationWorkerSaveReqVO updateReqVO) { |
| 45 | // 校验存在 | 47 | // 校验存在 |
| 46 | validateWorkstationWorkerExists(updateReqVO.getId()); | 48 | validateWorkstationWorkerExists(updateReqVO.getId()); |
| 49 | + // 校验数据 | ||
| 50 | + validateWorkstationWorkerSaveData(updateReqVO.getId(), updateReqVO); | ||
| 47 | 51 | ||
| 48 | // 更新 | 52 | // 更新 |
| 49 | MesMdWorkstationWorkerDO updateObj = BeanUtils.toBean(updateReqVO, MesMdWorkstationWorkerDO.class); | 53 | MesMdWorkstationWorkerDO updateObj = BeanUtils.toBean(updateReqVO, MesMdWorkstationWorkerDO.class); |
| 50 | workstationWorkerMapper.updateById(updateObj); | 54 | workstationWorkerMapper.updateById(updateObj); |
| 51 | } | 55 | } |
| 52 | 56 | ||
| 57 | + private void validateWorkstationWorkerSaveData(Long id, MesMdWorkstationWorkerSaveReqVO reqVO) { | ||
| 58 | + // 校验岗位是否存在 | ||
| 59 | + postApi.validPostList(Collections.singleton(reqVO.getPostId())); | ||
| 60 | + // 校验同一工作站下岗位不重复(排除自身) | ||
| 61 | + MesMdWorkstationWorkerDO existing = workstationWorkerMapper.selectByWorkstationIdAndPostId( | ||
| 62 | + reqVO.getWorkstationId(), reqVO.getPostId()); | ||
| 63 | + if (existing != null && ObjUtil.notEqual(existing.getId(), id)) { | ||
| 64 | + throw exception(MD_WORKSTATION_WORKER_POST_EXISTS); | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + | ||
| 53 | @Override | 68 | @Override |
| 54 | public void deleteWorkstationWorker(Long id) { | 69 | public void deleteWorkstationWorker(Long id) { |
| 55 | // 校验存在 | 70 | // 校验存在 |
| @@ -70,4 +85,9 @@ public class MesMdWorkstationWorkerServiceImpl implements MesMdWorkstationWorker | @@ -70,4 +85,9 @@ public class MesMdWorkstationWorkerServiceImpl implements MesMdWorkstationWorker | ||
| 70 | return workstationWorkerMapper.selectListByWorkstationId(workstationId); | 85 | return workstationWorkerMapper.selectListByWorkstationId(workstationId); |
| 71 | } | 86 | } |
| 72 | 87 | ||
| 88 | + @Override | ||
| 89 | + public void deleteWorkstationWorkerByWorkstationId(Long workstationId) { | ||
| 90 | + workstationWorkerMapper.deleteByWorkstationId(workstationId); | ||
| 91 | + } | ||
| 92 | + | ||
| 73 | } | 93 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ipqc/MesQcIpqcServiceImpl.java
| @@ -245,7 +245,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -245,7 +245,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | /** | 247 | /** |
| 248 | - * 推导工序 ID:对齐 KTG getProcessInfo() 逻辑 | 248 | + * 推导工序 ID |
| 249 | * | 249 | * |
| 250 | * <p>通过产品 → 工艺路线产品 → 工艺路线 → 校验工位工序是否在该路线中 | 250 | * <p>通过产品 → 工艺路线产品 → 工艺路线 → 校验工位工序是否在该路线中 |
| 251 | * <p>如果工位的工序在路线中,则返回该 processId;否则返回 null | 251 | * <p>如果工位的工序在路线中,则返回该 processId;否则返回 null |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/pendinginspect/MesQcPendingInspectServiceImpl.java
| @@ -12,8 +12,6 @@ import org.springframework.validation.annotation.Validated; | @@ -12,8 +12,6 @@ import org.springframework.validation.annotation.Validated; | ||
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * MES 待检任务 Service 实现类 | 14 | * MES 待检任务 Service 实现类 |
| 15 | - * | ||
| 16 | - * 使用 UNION ALL SQL 从多个来源表查询待检行,对齐 KTG 的 QcPendingInspectMapper.xml 实现 | ||
| 17 | */ | 15 | */ |
| 18 | @Service | 16 | @Service |
| 19 | @Validated | 17 | @Validated |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolTypeService.java
| @@ -65,6 +65,13 @@ public interface MesTmToolTypeService { | @@ -65,6 +65,13 @@ public interface MesTmToolTypeService { | ||
| 65 | List<MesTmToolTypeDO> getToolTypeList(); | 65 | List<MesTmToolTypeDO> getToolTypeList(); |
| 66 | 66 | ||
| 67 | /** | 67 | /** |
| 68 | + * 校验工具类型是否存在 | ||
| 69 | + * | ||
| 70 | + * @param id 编号 | ||
| 71 | + */ | ||
| 72 | + void validateToolTypeExists(Long id); | ||
| 73 | + | ||
| 74 | + /** | ||
| 68 | * 获得工具类型列表 | 75 | * 获得工具类型列表 |
| 69 | * | 76 | * |
| 70 | * @param ids 编号数组 | 77 | * @param ids 编号数组 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolTypeServiceImpl.java
| @@ -76,7 +76,8 @@ public class MesTmToolTypeServiceImpl implements MesTmToolTypeService { | @@ -76,7 +76,8 @@ public class MesTmToolTypeServiceImpl implements MesTmToolTypeService { | ||
| 76 | toolTypeMapper.deleteById(id); | 76 | toolTypeMapper.deleteById(id); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | - private void validateToolTypeExists(Long id) { | 79 | + @Override |
| 80 | + public void validateToolTypeExists(Long id) { | ||
| 80 | if (toolTypeMapper.selectById(id) == null) { | 81 | if (toolTypeMapper.selectById(id) == null) { |
| 81 | throw exception(TM_TOOL_TYPE_NOT_EXISTS); | 82 | throw exception(TM_TOOL_TYPE_NOT_EXISTS); |
| 82 | } | 83 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/outsourcereceipt/MesWmOutsourceReceiptServiceImpl.java
| @@ -237,7 +237,7 @@ public class MesWmOutsourceReceiptServiceImpl implements MesWmOutsourceReceiptSe | @@ -237,7 +237,7 @@ public class MesWmOutsourceReceiptServiceImpl implements MesWmOutsourceReceiptSe | ||
| 237 | outsourceReceiptLineService.createOutsourceReceiptLineDO(unqualifiedLine); | 237 | outsourceReceiptLineService.createOutsourceReceiptLineDO(unqualifiedLine); |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | - // 3. 直接更新主表状态为"待上架"(对齐 KTG:IQC 完成后直接推进状态) | 240 | + // 3. 直接更新主表状态为"待上架" |
| 241 | outsourceReceiptMapper.updateById(new MesWmOutsourceReceiptDO() | 241 | outsourceReceiptMapper.updateById(new MesWmOutsourceReceiptDO() |
| 242 | .setId(receiptId).setStatus(MesWmOutsourceReceiptStatusEnum.APPROVING.getStatus())); | 242 | .setId(receiptId).setStatus(MesWmOutsourceReceiptStatusEnum.APPROVING.getStatus())); |
| 243 | } | 243 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/transaction/MesWmTransactionService.java
| @@ -8,7 +8,6 @@ import java.util.List; | @@ -8,7 +8,6 @@ import java.util.List; | ||
| 8 | /** | 8 | /** |
| 9 | * MES 库存事务流水 Service 接口 | 9 | * MES 库存事务流水 Service 接口 |
| 10 | * | 10 | * |
| 11 | - * 对齐 KTG WmTransactionServiceImpl.processTransaction 实现: | ||
| 12 | * 校验 → 库存台账更新 → 事务流水插入。 | 11 | * 校验 → 库存台账更新 → 事务流水插入。 |
| 13 | */ | 12 | */ |
| 14 | public interface MesWmTransactionService { | 13 | public interface MesWmTransactionService { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/transaction/dto/MesWmTransactionSaveReqDTO.java
| @@ -96,8 +96,6 @@ public class MesWmTransactionSaveReqDTO { | @@ -96,8 +96,6 @@ public class MesWmTransactionSaveReqDTO { | ||
| 96 | private Long vendorId; | 96 | private Long vendorId; |
| 97 | /** | 97 | /** |
| 98 | * 入库时间(为空默认当前时间) | 98 | * 入库时间(为空默认当前时间) |
| 99 | - * | ||
| 100 | - * 对应 KTG 的 recptDate | ||
| 101 | */ | 99 | */ |
| 102 | private LocalDateTime receiptTime; | 100 | private LocalDateTime receiptTime; |
| 103 | 101 |