fix:修改模具上模为多选,新增下模相关接口

main
HuangHuiKang 21 hours ago
parent 628311098b
commit 1ad8100be1

@ -96,4 +96,11 @@ public class MoldController {
BeanUtils.toBean(list, MoldRespVO.class)); BeanUtils.toBean(list, MoldRespVO.class));
} }
@GetMapping("/getInTransitMoldAllList")
@Operation(summary = "获得上下模模具列表(在途-3")
public CommonResult<List<MoldDO>> getInTransitMoldAllList() {
List<MoldDO> doList = moldService.getInTransitMoldAllList();
return success(doList);
}
} }

@ -98,4 +98,6 @@ public interface MoldService {
} }
List<MoldRespVO> buildMoldVOList(List<MoldDO> list); List<MoldRespVO> buildMoldVOList(List<MoldDO> list);
List<MoldDO> getInTransitMoldAllList();
} }

@ -7,6 +7,7 @@ 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.erp.dal.dataobject.product.ErpProductUnitDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -108,4 +109,9 @@ public class MoldServiceImpl implements MoldService {
} }
return BeanUtils.toBean(list, MoldRespVO.class); return BeanUtils.toBean(list, MoldRespVO.class);
} }
@Override
public List<MoldDO> getInTransitMoldAllList() {
return moldMapper.selectList(Wrappers.<MoldDO>lambdaQuery().eq(MoldDO::getStatus,3));
}
} }

@ -30,7 +30,7 @@ public interface DeviceContactModelMapper extends BaseMapperX<DeviceContactModel
.eq(Objects.nonNull(device.getAttributeType()), DeviceContactModelDO::getAttributeType, device.getAttributeType()) .eq(Objects.nonNull(device.getAttributeType()), DeviceContactModelDO::getAttributeType, device.getAttributeType())
// 必要的条件如deviceModelId保留直接eq条件 // 必要的条件如deviceModelId保留直接eq条件
.eq(DeviceContactModelDO::getDeviceId, device.getDeviceId()) .eq(DeviceContactModelDO::getDeviceId, device.getDeviceId())
.orderByAsc(DeviceContactModelDO::getSort)); .orderByDesc(DeviceContactModelDO::getId));
} }

@ -49,7 +49,7 @@ public interface DeviceModelAttributeMapper extends BaseMapperX<DeviceModelAttri
.eqIfPresent(DeviceModelAttributeDO::getRemark, reqVO.getRemark()) .eqIfPresent(DeviceModelAttributeDO::getRemark, reqVO.getRemark())
.eqIfPresent(DeviceModelAttributeDO::getDeviceModelId, reqVO.getId()) .eqIfPresent(DeviceModelAttributeDO::getDeviceModelId, reqVO.getId())
.betweenIfPresent(DeviceModelAttributeDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(DeviceModelAttributeDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(DeviceModelAttributeDO::getCreateTime); .orderByDesc(DeviceModelAttributeDO::getId);
if(reqVO.getIds() !=null && StringUtils.isNotBlank(reqVO.getIds())){ if(reqVO.getIds() !=null && StringUtils.isNotBlank(reqVO.getIds())){

@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
import cn.iocoder.yudao.module.mes.service.deviceledger.DeviceLedgerService; 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.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.springframework.util.StringUtils;
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;
@ -25,6 +26,7 @@ import javax.validation.*;
import javax.servlet.http.*; import javax.servlet.http.*;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
import java.util.stream.Collectors;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -64,24 +66,41 @@ public class MoldOperateController {
@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")) { if (Objects.equals(createReqVO.getOperateType(), "1")) {
DeviceLedgerDO deviceLedger = deviceLedgerService.getDeviceLedger(createReqVO.getDeviceId()); DeviceLedgerDO deviceLedger = deviceLedgerService.getDeviceLedger(createReqVO.getDeviceId());
MoldDO moldDO = moldService.getMold(createReqVO.getMoldId()); List<Long> idList = Arrays.stream(createReqVO.getMoldId().split(","))
moldDO.setMachineId(createReqVO.getDeviceId()); .map(String::trim) // 去除可能存在的空格
moldDO.setMachineName(deviceLedger.getDeviceName()); .map(Long::valueOf)
moldDO.setStatus(0); // 在机 0 在库 1 .collect(Collectors.toList());
moldService.updateMold(BeanUtils.toBean(moldDO, MoldSaveReqVO.class)); for (Long id : idList) {
deviceLedger.setMoldId(Long.toString(createReqVO.getMoldId())); MoldDO moldDO = moldService.getMold(id);
moldDO.setMachineId(createReqVO.getDeviceId());
moldDO.setMachineName(deviceLedger.getDeviceName());
moldDO.setStatus(0); // 在机 0 在库 1
moldService.updateMold(BeanUtils.toBean(moldDO, MoldSaveReqVO.class));
}
deviceLedger.setMoldId(createReqVO.getMoldId());
deviceLedgerService.updateDeviceLedger(BeanUtils.toBean(deviceLedger, DeviceLedgerSaveReqVO.class)); deviceLedgerService.updateDeviceLedger(BeanUtils.toBean(deviceLedger, DeviceLedgerSaveReqVO.class));
} else { } else {
List<Long> lowerMoldId = Arrays.stream(createReqVO.getLowerMoldId().split(","))
.map(String::trim) // 去除可能存在的空格
.map(Long::valueOf)
.collect(Collectors.toList());
//下模
for (Long id : lowerMoldId) {
MoldDO moldDO = moldService.getMold(id);
moldDO.setMachineId(0L);
moldDO.setMachineName("");
moldDO.setStatus(3); // 在机 0 在途 3
moldService.updateMold(BeanUtils.toBean(moldDO, MoldSaveReqVO.class));
}
DeviceLedgerDO deviceLedger = deviceLedgerService.getDeviceLedger(createReqVO.getDeviceId()); DeviceLedgerDO deviceLedger = deviceLedgerService.getDeviceLedger(createReqVO.getDeviceId());
createReqVO.setMoldId(Long.parseLong(deviceLedger.getMoldId())); deviceLedger.setMoldId(createReqVO.getMoldId());
MoldDO moldDO = moldService.getMold(Long.parseLong(deviceLedger.getMoldId()));
moldDO.setMachineId(0L);
moldDO.setMachineName("");
moldDO.setStatus(3); // 在机 0 在库 1
moldService.updateMold(BeanUtils.toBean(moldDO, MoldSaveReqVO.class));
deviceLedger.setMoldId("0");
deviceLedgerService.updateDeviceLedger(BeanUtils.toBean(deviceLedger, DeviceLedgerSaveReqVO.class)); deviceLedgerService.updateDeviceLedger(BeanUtils.toBean(deviceLedger, DeviceLedgerSaveReqVO.class));
} }
return success(moldOperateService.createMoldOperate(createReqVO)); return success(moldOperateService.createMoldOperate(createReqVO));
@ -121,17 +140,18 @@ public class MoldOperateController {
// 管理员信息 // 管理员信息
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
convertSet(pageResult.getList(), admin -> Long.parseLong(admin.getCreator()))); convertSet(pageResult.getList(), admin -> Long.parseLong(admin.getCreator())));
// 模具信息
Map<Long, MoldRespVO> moldMap = moldService.getMoldVOMap( // // 模具信息
convertSet(pageResult.getList(), MoldOperateDO::getMoldId)); // Map<Long, MoldRespVO> moldMap = moldService.getMoldVOMap(
// convertSet(pageResult.getList(), MoldOperateDO::getMoldId));
// 设备台账 // 设备台账
Map<Long, DeviceLedgerRespVO> deviceLedgerMap = deviceLedgerService.getDeviceLedgerVOMap( // Map<Long, DeviceLedgerRespVO> deviceLedgerMap = deviceLedgerService.getDeviceLedgerVOMap(
convertSet(pageResult.getList(), MoldOperateDO::getDeviceId)); // convertSet(pageResult.getList(), MoldOperateDO::getDeviceId));
return success(BeanUtils.toBean(pageResult, MoldOperateRespVO.class,moldOperate -> { return success(BeanUtils.toBean(pageResult, MoldOperateRespVO.class,moldOperate -> {
MapUtils.findAndThen(userMap, Long.parseLong(moldOperate.getCreator()), user -> moldOperate.setCreatorName(user.getNickname())); MapUtils.findAndThen(userMap, Long.parseLong(moldOperate.getCreator()), user -> moldOperate.setCreatorName(user.getNickname()));
MapUtils.findAndThen(moldMap, moldOperate.getMoldId(), mold -> moldOperate.setMoldName(mold.getName())); // MapUtils.findAndThen(moldMap, moldOperate.getMoldId(), mold -> moldOperate.setMoldName(mold.getName()));
MapUtils.findAndThen(deviceLedgerMap, moldOperate.getDeviceId(), deviceLedger -> moldOperate.setDeviceName(deviceLedger.getDeviceName())); // MapUtils.findAndThen(deviceLedgerMap, moldOperate.getDeviceId(), deviceLedger -> moldOperate.setDeviceName(deviceLedger.getDeviceName()));
})); }));
} }
@ -162,4 +182,13 @@ public class MoldOperateController {
} }
@GetMapping("/getLowerMoldList")
@Operation(summary = "获得模具下模列表")
@Parameter(name = "id", description = "设备id", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('mes:mold-operate:query')")
public CommonResult<List<MoldDO>> getLowerMoldList(@RequestParam("id") Long id) {
List<MoldDO> moldDO = moldOperateService.getLowerMoldList(id);
return success(moldDO);
}
} }

@ -16,7 +16,7 @@ public class MoldOperateSaveReqVO {
private String operateType; private String operateType;
@Schema(description = "关联模具id", example = "23041") @Schema(description = "关联模具id", example = "23041")
private Long moldId; private String moldId;
@Schema(description = "关联设备id", example = "5057") @Schema(description = "关联设备id", example = "5057")
private Long deviceId; private Long deviceId;
@ -24,4 +24,7 @@ public class MoldOperateSaveReqVO {
@Schema(description = "备注", example = "随便") @Schema(description = "备注", example = "随便")
private String remark; private String remark;
@Schema(description = "下模模具id", example = "23041")
private String lowerMoldId;
} }

@ -34,7 +34,7 @@ public class MoldOperateDO extends BaseDO {
/** /**
* id * id
*/ */
private Long moldId; private String moldId;
/** /**
* id * id
*/ */
@ -44,4 +44,16 @@ public class MoldOperateDO extends BaseDO {
*/ */
private String remark; private String remark;
/**
*
*/
private String moldName;
/**
*
*/
private String deviceName;
} }

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.mes.service.moldoperate;
import java.util.*; import java.util.*;
import javax.validation.*; import javax.validation.*;
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
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;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -52,4 +54,7 @@ public interface MoldOperateService {
*/ */
PageResult<MoldOperateDO> getMoldOperatePage(MoldOperatePageReqVO pageReqVO); PageResult<MoldOperateDO> getMoldOperatePage(MoldOperatePageReqVO pageReqVO);
List<MoldDO> getLowerMoldList(Long id);
} }

@ -1,11 +1,19 @@
package cn.iocoder.yudao.module.mes.service.moldoperate; package cn.iocoder.yudao.module.mes.service.moldoperate;
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.common.dal.mysql.mold.MoldMapper;
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
import cn.iocoder.yudao.module.mes.dal.mysql.deviceledger.DeviceLedgerMapper;
import jodd.util.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
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;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -29,10 +37,40 @@ public class MoldOperateServiceImpl implements MoldOperateService {
@Resource @Resource
private MoldOperateMapper moldOperateMapper; private MoldOperateMapper moldOperateMapper;
@Resource
private DeviceLedgerMapper deviceLedgerMapper;
@Resource
private MoldMapper moldMapper;
@Override @Override
public Long createMoldOperate(MoldOperateSaveReqVO createReqVO) { public Long createMoldOperate(MoldOperateSaveReqVO createReqVO) {
// 插入 // 插入
MoldOperateDO moldOperate = BeanUtils.toBean(createReqVO, MoldOperateDO.class); MoldOperateDO moldOperate = BeanUtils.toBean(createReqVO, MoldOperateDO.class);
DeviceLedgerDO deviceLedgerDO = deviceLedgerMapper.selectById(createReqVO.getDeviceId());
moldOperate.setDeviceName(deviceLedgerDO.getDeviceName());
List<Long> idList = Arrays.stream(createReqVO.getMoldId().split(","))
.map(String::trim) // 去除可能存在的空格
.map(Long::valueOf)
.collect(Collectors.toList());
if (!idList.isEmpty()) {
StringBuilder moldNameBuilder = new StringBuilder();
for (Long id : idList) {
MoldDO moldDO = moldMapper.selectById(id);
if (moldDO != null && StringUtil.isNotBlank(moldDO.getName())) {
if (moldNameBuilder.length() > 0) {
moldNameBuilder.append(",");
}
moldNameBuilder.append(moldDO.getName());
}
}
moldOperate.setMoldName(moldNameBuilder.toString());
} else {
moldOperate.setMoldName("");
}
moldOperateMapper.insert(moldOperate); moldOperateMapper.insert(moldOperate);
// 返回 // 返回
return moldOperate.getId(); return moldOperate.getId();
@ -42,8 +80,34 @@ public class MoldOperateServiceImpl implements MoldOperateService {
public void updateMoldOperate(MoldOperateSaveReqVO updateReqVO) { public void updateMoldOperate(MoldOperateSaveReqVO updateReqVO) {
// 校验存在 // 校验存在
validateMoldOperateExists(updateReqVO.getId()); validateMoldOperateExists(updateReqVO.getId());
// 更新 // 更新
MoldOperateDO updateObj = BeanUtils.toBean(updateReqVO, MoldOperateDO.class); MoldOperateDO updateObj = BeanUtils.toBean(updateReqVO, MoldOperateDO.class);
DeviceLedgerDO deviceLedgerDO = deviceLedgerMapper.selectById(updateReqVO.getDeviceId());
updateObj.setDeviceName(deviceLedgerDO.getDeviceName());
List<Long> idList = Arrays.stream(updateReqVO.getMoldId().split(","))
.map(String::trim) // 去除可能存在的空格
.map(Long::valueOf)
.collect(Collectors.toList());
if (!idList.isEmpty()) {
StringBuilder moldNameBuilder = new StringBuilder();
for (Long id : idList) {
MoldDO moldDO = moldMapper.selectById(id);
if (moldDO != null && StringUtil.isNotBlank(moldDO.getName())) {
if (moldNameBuilder.length() > 0) {
moldNameBuilder.append(",");
}
moldNameBuilder.append(moldDO.getName());
}
}
updateObj.setMoldName(moldNameBuilder.toString());
} else {
updateObj.setMoldName("");
}
moldOperateMapper.updateById(updateObj); moldOperateMapper.updateById(updateObj);
} }
@ -71,4 +135,29 @@ public class MoldOperateServiceImpl implements MoldOperateService {
return moldOperateMapper.selectPage(pageReqVO); return moldOperateMapper.selectPage(pageReqVO);
} }
@Override
public List<MoldDO> getLowerMoldList(Long id) {
List<MoldDO> moldDOList = new ArrayList<>();
DeviceLedgerDO deviceLedgerDO = deviceLedgerMapper.selectById(id);
if (StringUtil.isBlank(deviceLedgerDO.getMoldId())){
return new ArrayList<>();
}
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){
moldDOList.add(moldDO);
}
}
return moldDOList;
}
} }
Loading…
Cancel
Save