fix:1、修改生产计划入库时可选仓库。2、修改产线只能选择一对一的采集设备。

ck
HuangHuiKang 1 month ago
parent f804a95f24
commit a6031a0c30

@ -110,6 +110,13 @@ public class DeviceController {
return success(pageResult);
}
@GetMapping("/available-list")
@Operation(summary = "获取设备下拉列表(全量+是否已选+已删除标识)")
@PreAuthorize("@ss.hasPermission('iot:device:query')")
public CommonResult<List<DeviceSelectRespVO>> getAvailableDeviceList() {
return success(deviceService.getDeviceSelectList());
}
@GetMapping("/export-excel")
@Operation(summary = "导出物联设备 Excel")
@PreAuthorize("@ss.hasPermission('iot:device:export')")

@ -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;
}

@ -127,4 +127,10 @@ public interface DeviceMapper extends BaseMapperX<DeviceDO> {
Integer getTotalDeviceCount();
List<Long> getAllDeviceIds();
List<DeviceSelectRespVO> selectDeviceSelectList();
// DeviceMapper.java
DeviceDO selectByIdWithDeleted(@Param("id") Long id);
}

@ -144,6 +144,9 @@ public interface DeviceService {
List<Long> deviceLedgerList();
List<DeviceSelectRespVO> getDeviceSelectList();
void updateDeviceEnabled(@Valid DeviceUpdateEnabledReqVO updateEnabledReqVO) throws MqttException;
DeviceDO getDeviceByMqttTopic(String topic);

@ -1707,4 +1707,9 @@ public class DeviceServiceImpl implements DeviceService {
return deviceMapper.deviceLedgerList();
}
@Override
public List<DeviceSelectRespVO> getDeviceSelectList() {
return deviceMapper.selectDeviceSelectList();
}
}

@ -204,4 +204,33 @@
WHERE deleted = 0
ORDER BY id
</select>
<select id="selectDeviceSelectList"
resultType="cn.iocoder.yudao.module.iot.controller.admin.device.vo.DeviceSelectRespVO">
SELECT
d.id,
d.device_code AS deviceCode,
d.device_name AS deviceName,
d.device_name AS displayName,
CASE
WHEN EXISTS (
SELECT 1
FROM mes_organization mo
WHERE mo.deleted = 0
AND mo.dv_id = d.id
) THEN TRUE
ELSE FALSE
END AS selected
FROM iot_device d
WHERE d.deleted = 0
ORDER BY d.id DESC
</select>
<select id="selectByIdWithDeleted"
resultType="cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceDO">
SELECT *
FROM iot_device
WHERE id = #{id}
LIMIT 1
</select>
</mapper>

@ -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不能为空");

@ -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<OrganizationRespVO> getOrganization(@RequestParam("id") Long id) {
OrganizationDO organization = organizationService.getOrganization(id);
return success(BeanUtils.toBean(organization, OrganizationRespVO.class));
return success(organizationService.getOrganizationVO(id));
}
@GetMapping("/list")

@ -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;
}

@ -55,6 +55,6 @@ public class OrganizationSaveReqVO {
private Long dvId;
@Schema(description = "关联采集设备")
private Long dvName;
private String dvName;
}

@ -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());

@ -20,5 +20,9 @@ public class PlanStatusUpdateVO {
@Schema(description = "更新状态", example = "21176")
private int status;
@Schema(description = "仓库Id", example = "21176")
private Long warehouseId;
}

@ -57,4 +57,6 @@ public interface DeviceLedgerMapper extends BaseMapperX<DeviceLedgerDO> {
List<DeviceLedgerDO> selectListByIds(@Param("ids") Collection<Long> ids);
DeviceLedgerDO selectByIdWithDeleted(@Param("id") Long id);
}

@ -79,5 +79,8 @@ public interface OrganizationService {
List<LineAnalysisTreeDTO.LineNode> deviceParameterAnalysis(String keyword,Integer showDevices);
OrganizationRespVO getOrganizationVO(Long id);
// List<DeviceParametersDTO> getDeviceParametersByOrganizationId(Long id);
}

@ -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;
}
}

@ -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);

@ -19,5 +19,13 @@
AND deleted = 0
</select>
<!-- DeviceLedgerMapper.xml -->
<select id="selectByIdWithDeleted"
resultType="cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO">
SELECT *
FROM mes_device_ledger
WHERE id = #{id}
LIMIT 1
</select>
</mapper>
Loading…
Cancel
Save