diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/DeviceController.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/DeviceController.java index 367d52d45..a4a57f7fd 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/DeviceController.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/DeviceController.java @@ -110,6 +110,13 @@ public class DeviceController { return success(pageResult); } + @GetMapping("/available-list") + @Operation(summary = "获取设备下拉列表(全量+是否已选+已删除标识)") + @PreAuthorize("@ss.hasPermission('iot:device:query')") + public CommonResult> getAvailableDeviceList() { + return success(deviceService.getDeviceSelectList()); + } + @GetMapping("/export-excel") @Operation(summary = "导出物联设备 Excel") @PreAuthorize("@ss.hasPermission('iot:device:export')") diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/DeviceSelectRespVO.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/DeviceSelectRespVO.java new file mode 100644 index 000000000..8dc62bf05 --- /dev/null +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/DeviceSelectRespVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.iot.controller.admin.device.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class DeviceSelectRespVO { + + @Schema(description = "设备ID") + private Long id; + + @Schema(description = "设备编码") + private String deviceCode; + + @Schema(description = "设备名称(原始)") + private String deviceName; + + @Schema(description = "设备名称(展示用,删除状态会拼接“(已删除)”)") + private String displayName; + + @Schema(description = "是否已被mes_organization.dv_id选择") + private Boolean selected; + +} diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/device/DeviceMapper.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/device/DeviceMapper.java index 8cf745cb2..ebfb92b5c 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/device/DeviceMapper.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/device/DeviceMapper.java @@ -127,4 +127,10 @@ public interface DeviceMapper extends BaseMapperX { Integer getTotalDeviceCount(); List getAllDeviceIds(); -} \ No newline at end of file + + List selectDeviceSelectList(); + + // DeviceMapper.java + DeviceDO selectByIdWithDeleted(@Param("id") Long id); + +} diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceService.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceService.java index bef1bee2d..14aadaf43 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceService.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceService.java @@ -144,7 +144,10 @@ public interface DeviceService { List deviceLedgerList(); + List getDeviceSelectList(); + + void updateDeviceEnabled(@Valid DeviceUpdateEnabledReqVO updateEnabledReqVO) throws MqttException; DeviceDO getDeviceByMqttTopic(String topic); -} \ No newline at end of file +} diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java index 8e90b0bd6..c6eae8d21 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java @@ -1707,4 +1707,9 @@ public class DeviceServiceImpl implements DeviceService { return deviceMapper.deviceLedgerList(); } + @Override + public List getDeviceSelectList() { + return deviceMapper.selectDeviceSelectList(); + } + } diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/DeviceMapper.xml b/yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/DeviceMapper.xml index f714cebc2..de5e59e83 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/DeviceMapper.xml +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/DeviceMapper.xml @@ -204,4 +204,33 @@ WHERE deleted = 0 ORDER BY id - \ No newline at end of file + + + + + diff --git a/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java b/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java index 110b3030c..98ee039a4 100644 --- a/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java +++ b/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java @@ -192,6 +192,7 @@ public interface ErrorCodeConstants { ErrorCode SCHEDULE_TIME_FORMAT_INVALID = new ErrorCode(100_301_0012, "排产时间格式错误,start={}, end={},格式需为HH:mm"); ErrorCode SCHEDULE_TIME_RANGE_INVALID = new ErrorCode(100_301_0013, "排产时间范围非法,start={}, end={},结束时间必须晚于开始时间"); ErrorCode SCHEDULE_WORK_HOURS_INVALID = new ErrorCode(100_301_0014, "排产工时非法,start={}, end={},可用工时必须大于0"); + ErrorCode WAREHOUSE_NOT_EXISTS= new ErrorCode(100_301_0014, "仓库Id不能为空"); diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/OrganizationController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/OrganizationController.java index 2819627f9..696a50f56 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/OrganizationController.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/OrganizationController.java @@ -56,13 +56,13 @@ public class OrganizationController { return success(true); } + @GetMapping("/get") @Operation(summary = "获得产线工位") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('mes:organization:query')") public CommonResult getOrganization(@RequestParam("id") Long id) { - OrganizationDO organization = organizationService.getOrganization(id); - return success(BeanUtils.toBean(organization, OrganizationRespVO.class)); + return success(organizationService.getOrganizationVO(id)); } @GetMapping("/list") diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/vo/OrganizationRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/vo/OrganizationRespVO.java index e6a1fa5cb..8b16f866e 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/vo/OrganizationRespVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/vo/OrganizationRespVO.java @@ -41,7 +41,7 @@ import java.time.LocalDateTime; private Long machineId; @Schema(description = "对应机台id", example = "17654") - @ExcelProperty("对应机台") + @ExcelProperty("对应机台(设备台账名称)") private String machineName; @Schema(description = "联系电话") @@ -83,7 +83,6 @@ import java.time.LocalDateTime; private Long dvId; @Schema(description = "关联采集设备") - @ExcelProperty("关联采集设备") - private Long dvName; - + @ExcelProperty("关联采集设备名称") + private String dvName; } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/vo/OrganizationSaveReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/vo/OrganizationSaveReqVO.java index 2bd27bd99..090b84040 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/vo/OrganizationSaveReqVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/organization/vo/OrganizationSaveReqVO.java @@ -55,6 +55,6 @@ public class OrganizationSaveReqVO { private Long dvId; @Schema(description = "关联采集设备") - private Long dvName; + private String dvName; } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/plan/PlanController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/plan/PlanController.java index 6940f43a3..5c1c6690c 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/plan/PlanController.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/plan/PlanController.java @@ -67,9 +67,11 @@ import java.util.*; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WAREHOUSE_NOT_EXISTS; import static org.apache.ibatis.ognl.OgnlOps.getIntValue; @Tag(name = "管理后台 - 生产计划") @@ -309,6 +311,9 @@ public class PlanController { } else if ("end".equals(code)) { planDO.setStatus(PlanStatusEnum.完工.getValue()); } else if ("store".equals(code)) { + if (statusUpdateVO.getWarehouseId() ==null ){ + throw exception(WAREHOUSE_NOT_EXISTS); + } planDO.setStatus(PlanStatusEnum.已入库.getValue()); } else if ("commence".equals(code)) { planDO.setStatus(PlanStatusEnum.已开工.getValue()); diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/plan/vo/PlanStatusUpdateVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/plan/vo/PlanStatusUpdateVO.java index b2f9d6604..cab563fea 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/plan/vo/PlanStatusUpdateVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/plan/vo/PlanStatusUpdateVO.java @@ -20,5 +20,9 @@ public class PlanStatusUpdateVO { @Schema(description = "更新状态", example = "21176") private int status; + @Schema(description = "仓库Id", example = "21176") + private Long warehouseId; + + } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceledger/DeviceLedgerMapper.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceledger/DeviceLedgerMapper.java index 62816d4ce..e8fdeb50e 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceledger/DeviceLedgerMapper.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/deviceledger/DeviceLedgerMapper.java @@ -57,4 +57,6 @@ public interface DeviceLedgerMapper extends BaseMapperX { List selectListByIds(@Param("ids") Collection ids); + DeviceLedgerDO selectByIdWithDeleted(@Param("id") Long id); + } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationService.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationService.java index db9d11463..9304a9b0d 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationService.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationService.java @@ -79,5 +79,8 @@ public interface OrganizationService { List deviceParameterAnalysis(String keyword,Integer showDevices); + OrganizationRespVO getOrganizationVO(Long id); + + // List getDeviceParametersByOrganizationId(Long id); } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationServiceImpl.java index 9489e078c..a0e3d625a 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationServiceImpl.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/organization/OrganizationServiceImpl.java @@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.orgworker.vo.OrgWorkerPageRe import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO; import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO; import cn.iocoder.yudao.module.mes.dal.dataobject.orgworker.OrgWorkerDO; +import cn.iocoder.yudao.module.mes.dal.mysql.deviceledger.DeviceLedgerMapper; import cn.iocoder.yudao.module.mes.dal.mysql.organization.OrganizationMapper; import cn.iocoder.yudao.module.mes.dal.mysql.orgworker.OrgWorkerMapper; import cn.iocoder.yudao.module.mes.dal.redis.no.MesNoRedisDAO; @@ -28,6 +29,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -66,6 +68,9 @@ public class OrganizationServiceImpl implements OrganizationService { @Resource private DeviceLedgerService deviceLedgerService; + @Resource + @Lazy + private DeviceLedgerMapper deviceLedgerMapper; @Autowired private AutoCodeUtil autoCodeUtil; @@ -731,4 +736,46 @@ public class OrganizationServiceImpl implements OrganizationService { .build(); } + + // OrganizationServiceImpl.java + @Override + public OrganizationRespVO getOrganizationVO(Long id) { + OrganizationDO organization = organizationMapper.selectById(id); + if (organization == null) { + return null; + } + + OrganizationRespVO respVO = BeanUtils.toBean(organization, OrganizationRespVO.class); + + if (organization.getMachineId() != null) { + DeviceLedgerDO ledger = deviceLedgerMapper.selectByIdWithDeleted(organization.getMachineId()); + if (ledger != null) { + String machineName = (ledger.getDeviceCode() == null ? "" : ledger.getDeviceCode()) + + "-" + + (ledger.getDeviceName() == null ? "" : ledger.getDeviceName()); + if (Boolean.TRUE.equals(ledger.getDeleted())) { + machineName += "(已被删除)"; + } + respVO.setMachineName(machineName); + } + } + + if (organization.getDvId() != null) { + DeviceDO device = deviceMapper.selectByIdWithDeleted(organization.getDvId()); + if (device != null) { + String deviceName = (device.getDeviceCode() == null ? "" : device.getDeviceCode()) + + "-" + + (device.getDeviceName() == null ? "" : device.getDeviceName()); + if (Boolean.TRUE.equals(device.getDeleted())) { + deviceName += "(已被删除)"; + } + respVO.setDvName(deviceName); + } + } + + return respVO; + } + + + } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/plan/PlanServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/plan/PlanServiceImpl.java index cb5803707..f5b84f253 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/plan/PlanServiceImpl.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/plan/PlanServiceImpl.java @@ -262,7 +262,7 @@ public class PlanServiceImpl implements PlanService { stockIn.setInType("产品入库"); ErpStockInSaveReqVO.Item item = new ErpStockInSaveReqVO.Item(); // todo 修改仓库 - item.setWarehouseId(12L); + item.setWarehouseId(statusUpdateVO.getWarehouseId()); item.setProductId(planDO.getProductId()); if (planDO.getPassNumber() == null) { planDO.setPassNumber(0L); diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/deviceledger/DeviceledgerMapper.xml b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/deviceledger/DeviceledgerMapper.xml index bc02b73a0..4e462d073 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/deviceledger/DeviceledgerMapper.xml +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/deviceledger/DeviceledgerMapper.xml @@ -19,5 +19,13 @@ AND deleted = 0 + + \ No newline at end of file