上下模

plp
kkk-ops 3 weeks ago
parent 875a5c92bc
commit 5eee19fb4e

@ -28,7 +28,6 @@ public class MoldBrandSaveReqVO {
private String moldType; private String moldType;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2336") @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2336")
@NotNull(message = "产品ID不能为空")
private Long productId; private Long productId;
@Schema(description = "预期寿命(小时)") @Schema(description = "预期寿命(小时)")

@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.criticalcomponent.CriticalComponentDO; import cn.iocoder.yudao.module.mes.dal.dataobject.criticalcomponent.CriticalComponentDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.dvrepair.DvRepairLineDO; import cn.iocoder.yudao.module.mes.dal.dataobject.dvrepair.DvRepairLineDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.ticketresults.TicketResultsDO; import cn.iocoder.yudao.module.mes.dal.dataobject.ticketresults.TicketResultsDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@ -125,6 +126,9 @@ public class DeviceLedgerRespVO extends BaseDO {
@Schema(description = "备件列表") @Schema(description = "备件列表")
private List<ErpProductDO> beijianList; private List<ErpProductDO> beijianList;
@Schema(description = "模具列表")
private List<MoldDO> moldList;
@Schema(description = "附件地址") @Schema(description = "附件地址")
@ExcelProperty("附件地址") @ExcelProperty("附件地址")
private String fileUrl; private String fileUrl;
@ -134,4 +138,7 @@ public class DeviceLedgerRespVO extends BaseDO {
@Schema(description = "备件id") @Schema(description = "备件id")
private String beijianId; private String beijianId;
@Schema(description = "模具id")
private String moldId;
} }

@ -70,6 +70,9 @@ public class DeviceLedgerSaveReqVO {
@Schema(description = "关键件ids集合") @Schema(description = "关键件ids集合")
private String componentId; private String componentId;
@Schema(description = "关键ids集合") @Schema(description = "ids集合")
private String beijianId; private String beijianId;
@Schema(description = "模具ids集合")
private String moldId;
} }

@ -1,5 +1,17 @@
package cn.iocoder.yudao.module.mes.controller.admin.moldoperate; package cn.iocoder.yudao.module.mes.controller.admin.moldoperate;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO;
import cn.iocoder.yudao.module.erp.service.mold.MoldService;
import cn.iocoder.yudao.module.mes.controller.admin.deviceledger.vo.DeviceLedgerRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.deviceledger.vo.DeviceLedgerSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
import cn.iocoder.yudao.module.mes.service.deviceledger.DeviceLedgerService;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -24,6 +36,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import cn.iocoder.yudao.module.mes.controller.admin.moldoperate.vo.*; import cn.iocoder.yudao.module.mes.controller.admin.moldoperate.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.moldoperate.MoldOperateDO; import cn.iocoder.yudao.module.mes.dal.dataobject.moldoperate.MoldOperateDO;
@ -38,10 +51,37 @@ public class MoldOperateController {
@Resource @Resource
private MoldOperateService moldOperateService; private MoldOperateService moldOperateService;
@Resource
private AdminUserApi adminUserApi;
@Resource
private MoldService moldService;
@Resource
private DeviceLedgerService deviceLedgerService;
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建模具上下模") @Operation(summary = "创建模具上下模")
@PreAuthorize("@ss.hasPermission('mes:mold-operate:create')") @PreAuthorize("@ss.hasPermission('mes:mold-operate:create')")
public CommonResult<Long> createMoldOperate(@Valid @RequestBody MoldOperateSaveReqVO createReqVO) { public CommonResult<Long> createMoldOperate(@Valid @RequestBody MoldOperateSaveReqVO createReqVO) {
if (Objects.equals(createReqVO.getOperateType(), "1")) {
MoldDO moldDO = moldService.getMold(createReqVO.getMoldId());
moldDO.setMachineId(createReqVO.getDeviceId());
moldDO.setStatus(0); // 在机 0 在库 1
moldService.updateMold(BeanUtils.toBean(moldDO, MoldSaveReqVO.class));
DeviceLedgerDO deviceLedger = deviceLedgerService.getDeviceLedger(createReqVO.getDeviceId());
deviceLedger.setMoldId(Long.toString(createReqVO.getMoldId()));
deviceLedgerService.updateDeviceLedger(BeanUtils.toBean(deviceLedger, DeviceLedgerSaveReqVO.class));
} else {
DeviceLedgerDO deviceLedger = deviceLedgerService.getDeviceLedger(createReqVO.getDeviceId());
createReqVO.setMoldId(Long.parseLong(deviceLedger.getMoldId()));
MoldDO moldDO = moldService.getMold(Long.parseLong(deviceLedger.getMoldId()));
moldDO.setMachineId(0L);
moldDO.setStatus(3); // 在机 0 在库 1
moldService.updateMold(BeanUtils.toBean(moldDO, MoldSaveReqVO.class));
deviceLedger.setMoldId("0");
deviceLedgerService.updateDeviceLedger(BeanUtils.toBean(deviceLedger, DeviceLedgerSaveReqVO.class));
}
return success(moldOperateService.createMoldOperate(createReqVO)); return success(moldOperateService.createMoldOperate(createReqVO));
} }
@ -76,7 +116,21 @@ public class MoldOperateController {
@PreAuthorize("@ss.hasPermission('mes:mold-operate:query')") @PreAuthorize("@ss.hasPermission('mes:mold-operate:query')")
public CommonResult<PageResult<MoldOperateRespVO>> getMoldOperatePage(@Valid MoldOperatePageReqVO pageReqVO) { public CommonResult<PageResult<MoldOperateRespVO>> getMoldOperatePage(@Valid MoldOperatePageReqVO pageReqVO) {
PageResult<MoldOperateDO> pageResult = moldOperateService.getMoldOperatePage(pageReqVO); PageResult<MoldOperateDO> pageResult = moldOperateService.getMoldOperatePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, MoldOperateRespVO.class)); // 管理员信息
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
convertSet(pageResult.getList(), admin -> Long.parseLong(admin.getCreator())));
// 模具信息
Map<Long, MoldRespVO> moldMap = moldService.getMoldVOMap(
convertSet(pageResult.getList(), MoldOperateDO::getMoldId));
// 设备台账
Map<Long, DeviceLedgerRespVO> deviceLedgerMap = deviceLedgerService.getDeviceLedgerVOMap(
convertSet(pageResult.getList(), MoldOperateDO::getDeviceId));
return success(BeanUtils.toBean(pageResult, MoldOperateRespVO.class,moldOperate -> {
MapUtils.findAndThen(userMap, Long.parseLong(moldOperate.getCreator()), user -> moldOperate.setCreatorName(user.getNickname()));
MapUtils.findAndThen(moldMap, moldOperate.getMoldId(), mold -> moldOperate.setMoldName(mold.getName()));
MapUtils.findAndThen(deviceLedgerMap, moldOperate.getDeviceId(), deviceLedger -> moldOperate.setDeviceName(deviceLedger.getDeviceName()));
}));
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@ -92,4 +146,18 @@ public class MoldOperateController {
BeanUtils.toBean(list, MoldOperateRespVO.class)); BeanUtils.toBean(list, MoldOperateRespVO.class));
} }
@GetMapping("/get-mold")
@Operation(summary = "获得设备是否有模具")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('mes:mold-operate:query')")
public CommonResult<Boolean> getDeviceLedgerLMold(@RequestParam("id") Long id) {
DeviceLedgerDO deviceLedgerDO = deviceLedgerService.getDeviceLedger(id);
if (deviceLedgerDO.getMoldId() != null && !deviceLedgerDO.getMoldId().isEmpty() && Integer.parseInt(deviceLedgerDO.getMoldId()) != 0) {
return success(true);
} else {
return success(false);
}
}
} }

@ -21,12 +21,21 @@ public class MoldOperatePageReqVO extends PageParam {
@Schema(description = "关联模具id", example = "23041") @Schema(description = "关联模具id", example = "23041")
private Long moldId; private Long moldId;
@Schema(description = "关联模具名称", example = "5057")
private String moldName;
@Schema(description = "关联设备id", example = "5057") @Schema(description = "关联设备id", example = "5057")
private Long deviceId; private Long deviceId;
@Schema(description = "关联设备名称", example = "5057")
private String deviceName;
@Schema(description = "备注", example = "随便") @Schema(description = "备注", example = "随便")
private String remark; private String remark;
@Schema(description = "创建人", example = "随便")
private String Creator;
@Schema(description = "创建时间") @Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;

@ -21,13 +21,19 @@ public class MoldOperateRespVO {
private String operateType; private String operateType;
@Schema(description = "关联模具id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23041") @Schema(description = "关联模具id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23041")
@ExcelProperty("关联模具id")
private Long moldId; private Long moldId;
@Schema(description = "关联模具", example = "5057")
@ExcelProperty("关联模具")
private String moldName;
@Schema(description = "关联设备id", example = "5057") @Schema(description = "关联设备id", example = "5057")
@ExcelProperty("关联设备id")
private Long deviceId; private Long deviceId;
@Schema(description = "关联设备", example = "5057")
@ExcelProperty("关联设备")
private String deviceName;
@Schema(description = "备注", example = "随便") @Schema(description = "备注", example = "随便")
@ExcelProperty("备注") @ExcelProperty("备注")
private String remark; private String remark;
@ -36,4 +42,9 @@ public class MoldOperateRespVO {
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "创建人", example = "芋道")
private String creator;
@Schema(description = "创建人名称", example = "芋道")
private String creatorName;
} }

@ -15,8 +15,7 @@ public class MoldOperateSaveReqVO {
@Schema(description = "操作类型", example = "2") @Schema(description = "操作类型", example = "2")
private String operateType; private String operateType;
@Schema(description = "关联模具id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23041") @Schema(description = "关联模具id", example = "23041")
@NotNull(message = "关联模具id不能为空")
private Long moldId; private Long moldId;
@Schema(description = "关联设备id", example = "5057") @Schema(description = "关联设备id", example = "5057")

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger; package cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.criticalcomponent.CriticalComponentDO; import cn.iocoder.yudao.module.mes.dal.dataobject.criticalcomponent.CriticalComponentDO;
@ -146,4 +147,15 @@ public class DeviceLedgerDO extends BaseDO {
@TableField(exist = false) @TableField(exist = false)
private List<ErpProductDO> beijianList; private List<ErpProductDO> beijianList;
/**
* id
*/
private String moldId;
/**
*
*/
@TableField(exist = false)
private List<MoldDO> moldList;
} }

@ -2,10 +2,15 @@ package cn.iocoder.yudao.module.mes.service.deviceledger;
import java.util.*; import java.util.*;
import javax.validation.*; import javax.validation.*;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.mes.controller.admin.deviceledger.vo.*; import cn.iocoder.yudao.module.mes.controller.admin.deviceledger.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO; import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
/** /**
* Service * Service
* *
@ -51,4 +56,23 @@ public interface DeviceLedgerService {
*/ */
PageResult<DeviceLedgerDO> getDeviceLedgerPage(DeviceLedgerPageReqVO pageReqVO); PageResult<DeviceLedgerDO> getDeviceLedgerPage(DeviceLedgerPageReqVO pageReqVO);
/**
* VO
*
* @param ids
* @return VO
*/
List<DeviceLedgerRespVO> getDeviceLedgerVOList(Collection<Long> ids);
/**
* VO Map
*
* @param ids
* @return VO Map
*/
default Map<Long, DeviceLedgerRespVO> getDeviceLedgerVOMap(Collection<Long> ids) {
if(ids.isEmpty())return new HashMap<>();
return convertMap(getDeviceLedgerVOList(ids), DeviceLedgerRespVO::getId);
}
} }

@ -1,8 +1,14 @@
package cn.iocoder.yudao.module.mes.service.deviceledger; package cn.iocoder.yudao.module.mes.service.deviceledger;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper; import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper;
import cn.iocoder.yudao.module.iot.dal.dataobject.devicemodel.DeviceModelDO;
import cn.iocoder.yudao.module.mes.controller.admin.ticketmanagement.enums.PlanTypeEnum; import cn.iocoder.yudao.module.mes.controller.admin.ticketmanagement.enums.PlanTypeEnum;
import cn.iocoder.yudao.module.mes.dal.dataobject.criticalcomponent.CriticalComponentDO; import cn.iocoder.yudao.module.mes.dal.dataobject.criticalcomponent.CriticalComponentDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.dvrepair.DvRepairDO; import cn.iocoder.yudao.module.mes.dal.dataobject.dvrepair.DvRepairDO;
@ -32,7 +38,6 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.mes.dal.mysql.deviceledger.DeviceLedgerMapper; import cn.iocoder.yudao.module.mes.dal.mysql.deviceledger.DeviceLedgerMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.DEVICE_MODEL_CODE_EXISTS;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
/** /**
@ -63,6 +68,9 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
@Resource @Resource
private ErpProductMapper productMapper; private ErpProductMapper productMapper;
@Resource
private MoldMapper moldMapper;
@Override @Override
public Long createDeviceLedger(DeviceLedgerSaveReqVO createReqVO) { public Long createDeviceLedger(DeviceLedgerSaveReqVO createReqVO) {
@ -177,6 +185,23 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
deviceLedgerDO.setComponentList(componentList); deviceLedgerDO.setComponentList(componentList);
} }
//模具列表
List<MoldDO> moldList = new ArrayList<>();
if (StringUtils.isNotBlank(deviceLedgerDO.getMoldId())) {
// 将逗号分隔的字符串转换为Long类型的List
List<Long> idList = Arrays.stream(deviceLedgerDO.getMoldId().split(","))
.map(String::trim) // 去除可能存在的空格
.map(Long::valueOf)
.collect(Collectors.toList());
for (Long moldId : idList) {
MoldDO moldDO = moldMapper.selectById(moldId);
if(moldDO!=null){
moldList.add(moldDO);
}
}
deviceLedgerDO.setMoldList(moldList);
}
//备件列表 //备件列表
List<ErpProductDO> beijianList = new ArrayList<>(); List<ErpProductDO> beijianList = new ArrayList<>();
if (StringUtils.isNotBlank(deviceLedgerDO.getBeijianId())) { if (StringUtils.isNotBlank(deviceLedgerDO.getBeijianId())) {
@ -201,4 +226,14 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
return deviceLedgerMapper.selectPage(pageReqVO); return deviceLedgerMapper.selectPage(pageReqVO);
} }
@Override
public List<DeviceLedgerRespVO> getDeviceLedgerVOList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
List<DeviceLedgerDO> list = deviceLedgerMapper.selectBatchIds(ids);
return BeanUtils.toBean(list, DeviceLedgerRespVO.class);
}
} }
Loading…
Cancel
Save