kkk-ops 2 months ago
commit d9acb82982

@ -90,8 +90,9 @@ public class MoldBrandController {
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<MoldBrandRespVO> list = moldBrandService.getMoldBrandPage(pageReqVO).getList();
List<MoldBrandRespVO> moldBrandRespVOS = BeanUtils.toBean(list, MoldBrandRespVO.class);
// 导出 Excel
ExcelUtils.write(response, "模具型号.xls", "数据", MoldBrandRespVO.class, list);
ExcelUtils.write(response, "模具型号.xls", "数据", MoldBrandRespVO.class, moldBrandRespVOS);
}
// ==================== 子表(模具) ====================

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum OrgTypeStatusEnum {
zhijiang("zhijiang", "制浆"),
duidie("duidie", "堆叠"),
chengxing("chengxing", "成型"),
honggan("honggan", "烘干"),
zhuanyi("zhuanyi", "转移"),
jiashi("jiashi", "加湿"),
reya("reya", "热压"),
qiebian("qiebian", "切边"),
pinjian("pinjian", "品检"),
dabao("dabao", "打包"),
tiebiao("tiebiao", "贴标"),
sufeng("sufeng", "塑封"),
pinyin("pinyin", "品印");
private final String orgtype;
private final String description;
public static OrgTypeStatusEnum getByCode(String code) {
for (OrgTypeStatusEnum status : values()) {
if (status.getOrgtype().equals(code)) {
return status;
}
}
return null;
}
}

@ -53,4 +53,7 @@ public class MoldBrandPageReqVO extends PageParam {
@Schema(description = "工序", example = "你说的对")
private String orgType;
@Schema(description = "id集合导出用")
private String ids;
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -11,6 +12,7 @@ import com.alibaba.excel.annotation.*;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 模具型号 Response VO")
@Data
@ExcelIgnoreUnannotated
@ -35,24 +37,24 @@ public class MoldBrandRespVO {
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2336")
private Long productId;
@Schema(description = "产品", requiredMode = Schema.RequiredMode.REQUIRED, example = "2336")
@ExcelProperty("产品")
// @ExcelProperty("产品")
private String productName;
@Schema(description = "预期寿命(小时)")
@ExcelProperty("预期寿命(小时)")
@Schema(description = "预期寿命/次")
@ExcelProperty("预期寿命/次")
private BigDecimal useTime;
@Schema(description = "维保模式", example = "2")
@ExcelProperty(value = "维保模式", converter = DictConvert.class)
// @ExcelProperty(value = "维保模式", converter = DictConvert.class)
@DictFormat("maintain_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private Integer maintainType;
@Schema(description = "维保周期")
@ExcelProperty("维保周期")
// @ExcelProperty("维保周期")
private BigDecimal maintainTime;
@Schema(description = "模具系数", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("模具系数")
@Schema(description = "模数", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("模数")
private Long moldSize;
@Schema(description = "备注", example = "你说的对")
@ -60,14 +62,17 @@ public class MoldBrandRespVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否启用")
// @ExcelProperty("是否启用")
private Boolean isEnable;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
@ColumnWidth(20)
private LocalDateTime createTime;
@Schema(description = "工序", example = "你说的对")
@DictFormat("mes_org_type")
@ExcelProperty(value = "工序")
private String orgType;
// , converter = OrgTypeConverter.class
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
@ -54,4 +55,10 @@ public class MoldPageReqVO extends PageParam {
@Schema(description = "型号id", example = "15258")
private Long brandId;
@Schema(description = "id集合导出用")
private String ids;
// @Schema(description = "机台名字")
// private String machineName;
}

@ -34,15 +34,15 @@ public class MoldRespVO {
@Schema(description = "单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "19527")
private Long unitId;
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个")
@ExcelProperty("单位")
// @ExcelProperty("单位")
private String unitName;
@Schema(description = "机台ID", example = "24428")
@ExcelProperty("机台ID")
@Schema(description = "设备ID", example = "24428")
@ExcelProperty("使用设备")
private Long machineId;
@Schema(description = "使用时间(小时)")
@ExcelProperty("使用时间(小时)")
@Schema(description = "使用次数/次")
@ExcelProperty("使用次数/次")
private BigDecimal useTime;
@Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ -56,7 +56,7 @@ public class MoldRespVO {
private Integer status;
@Schema(description = "模具图片")
@ExcelProperty("模具图片")
// @ExcelProperty("模具图片")
private String images;
@Schema(description = "备注", example = "你猜")
@ -64,15 +64,19 @@ public class MoldRespVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否启用")
// @ExcelProperty("是否启用")
private Boolean isEnable;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
// @ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "型号id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15258")
@ExcelProperty("型号id")
private Long brandId;
@Schema(description = "附件地址")
@ExcelProperty("附件地址")
private String fileUrl;
}

@ -0,0 +1,86 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import cn.iocoder.yudao.module.erp.controller.admin.mold.enums.OrgTypeStatusEnum;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import org.springframework.stereotype.Component;
/**
*
*/
@Component
public class OrgTypeConverter implements Converter<String> { // 泛型改为 String对应英文字符串
/**
* ExcelExcel/ Java
*/
@Override
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
String cellValue = cellData.getStringValue();
if (cellValue == null || cellValue.trim().isEmpty()) {
return null;
}
// 优先匹配中文 → 转换为对应的英文常量名
for (OrgTypeStatusEnum status : OrgTypeStatusEnum.values()) {
if (status.getDescription().equals(cellValue)) { // 注意枚举的描述方法是 getDesc
return status.name(); // 返回枚举的英文常量名(如 IN_USE
}
}
// 匹配英文 → 直接返回兼容Excel中填英文的场景
for (OrgTypeStatusEnum status : OrgTypeStatusEnum.values()) {
if (status.name().equals(cellValue)) {
return cellValue;
}
}
// 无匹配则抛出异常
throw new IllegalArgumentException("设备状态格式错误: " + cellValue + ",仅支持中文(在机/在库/维修中/保养中/报废或英文IN_USE/IN_STOCK/UNDER_REPAIR/UNDER_MAINTENANCE/SCRAPPED");
}
/**
* ExcelJava Excel
*/
@Override
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (value == null || value.trim().isEmpty()) {
return new WriteCellData<>("");
}
// 根据英文常量名匹配枚举,转换为中文
OrgTypeStatusEnum status = null;
try {
status = OrgTypeStatusEnum.valueOf(value); // 通过英文名称获取枚举
} catch (IllegalArgumentException e) {
// 若英文匹配失败,尝试兜底匹配中文(兼容异常场景)
for (OrgTypeStatusEnum s : OrgTypeStatusEnum.values()) {
if (s.getDescription().equals(value)) {
status = s;
break;
}
}
}
String text = status != null ? status.getDescription() : "未知";
return new WriteCellData<>(text);
}
// 必须实现的接口方法指定转换的Java类型
@Override
public Class<?> supportJavaTypeKey() {
return String.class;
}
// 必须实现的接口方法指定Excel单元格类型
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
}

@ -5,9 +5,13 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldBrandPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import com.alibaba.excel.util.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* Mapper
@ -18,7 +22,23 @@ import java.util.List;
public interface MoldBrandMapper extends BaseMapperX<MoldBrandDO> {
default PageResult<MoldBrandDO> selectPage(MoldBrandPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MoldBrandDO>()
// return selectPage(reqVO, new LambdaQueryWrapperX<MoldBrandDO>()
// .eqIfPresent(MoldBrandDO::getCode, reqVO.getCode())
// .likeIfPresent(MoldBrandDO::getName, reqVO.getName())
// .eqIfPresent(MoldBrandDO::getMoldType, reqVO.getMoldType())
// .eqIfPresent(MoldBrandDO::getProductId, reqVO.getProductId())
// .eqIfPresent(MoldBrandDO::getUseTime, reqVO.getUseTime())
// .eqIfPresent(MoldBrandDO::getMaintainType, reqVO.getMaintainType())
// .eqIfPresent(MoldBrandDO::getMaintainTime, reqVO.getMaintainTime())
// .eqIfPresent(MoldBrandDO::getMoldSize, reqVO.getMoldSize())
// .eqIfPresent(MoldBrandDO::getRemark, reqVO.getRemark())
// .eqIfPresent(MoldBrandDO::getIsEnable, reqVO.getIsEnable())
// .eqIfPresent(MoldBrandDO::getOrgType, reqVO.getOrgType())
// .betweenIfPresent(MoldBrandDO::getCreateTime, reqVO.getCreateTime())
// .orderByDesc(MoldBrandDO::getId));
LambdaQueryWrapperX<MoldBrandDO> moldBrandDOLambdaQueryWrapperX = new LambdaQueryWrapperX<>();
moldBrandDOLambdaQueryWrapperX
.eqIfPresent(MoldBrandDO::getCode, reqVO.getCode())
.likeIfPresent(MoldBrandDO::getName, reqVO.getName())
.eqIfPresent(MoldBrandDO::getMoldType, reqVO.getMoldType())
@ -29,8 +49,24 @@ public interface MoldBrandMapper extends BaseMapperX<MoldBrandDO> {
.eqIfPresent(MoldBrandDO::getMoldSize, reqVO.getMoldSize())
.eqIfPresent(MoldBrandDO::getRemark, reqVO.getRemark())
.eqIfPresent(MoldBrandDO::getIsEnable, reqVO.getIsEnable())
.eqIfPresent(MoldBrandDO::getOrgType, reqVO.getOrgType())
.betweenIfPresent(MoldBrandDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MoldBrandDO::getId));
.orderByDesc(MoldBrandDO::getId);
// 单独处理 ids 条件
if (StringUtils.isNotBlank(reqVO.getIds())) {
List<Long> idList = Arrays.stream(reqVO.getIds().split(","))
.map(String::trim)
.map(Long::valueOf)
.collect(Collectors.toList());
moldBrandDOLambdaQueryWrapperX.in(MoldBrandDO::getId, idList);
}
return selectPage(reqVO, moldBrandDOLambdaQueryWrapperX);
}
default List<MoldBrandDO> selectBy(MoldBrandPageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<MoldBrandDO>()
@ -44,6 +80,7 @@ public interface MoldBrandMapper extends BaseMapperX<MoldBrandDO> {
.eqIfPresent(MoldBrandDO::getMoldSize, reqVO.getMoldSize())
.eqIfPresent(MoldBrandDO::getRemark, reqVO.getRemark())
.eqIfPresent(MoldBrandDO::getIsEnable, reqVO.getIsEnable())
.eqIfPresent(MoldBrandDO::getOrgType, reqVO.getOrgType())
.betweenIfPresent(MoldBrandDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MoldBrandDO::getId));
}

@ -91,11 +91,13 @@ public class MoldBrandServiceImpl implements MoldBrandService {
public List<MoldBrandDO> selectBy(MoldBrandPageReqVO reqVO){
return moldBrandMapper.selectBy(reqVO);
}
@Override
public PageResult<MoldBrandRespVO> getMoldBrandPage(MoldBrandPageReqVO pageReqVO) {
PageResult<MoldBrandDO> pageResult = moldBrandMapper.selectPage(pageReqVO);
return new PageResult<>(buildMoldBrandVOList(pageResult.getList()),pageResult.getTotal());
return new PageResult<>(buildMoldBrandVOList(pageResult.getList()), pageResult.getTotal());
}
private List<MoldBrandRespVO> buildMoldBrandVOList(List<MoldBrandDO> list) {
if (CollUtil.isEmpty(list)) {
return Collections.emptyList();

@ -20,6 +20,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -43,28 +44,29 @@ public class DeviceJob implements JobHandler {
// 解析JSON字符串获取deviceId
JSONObject jsonParam = JSON.parseObject(param);
Long deviceId = jsonParam.getLong("deviceId");
log.info("定时任务执行,接收到的参数 param: {}", param);
if (deviceId == null){
throw exception(DEVICE_DOES_NOT_EXIST);
}
System.out.println(jsonParam + new Date().toString());
// Long deviceId = jsonParam.getLong("deviceId");
// log.info("定时任务执行,接收到的参数 param: {}", param);
// if (deviceId == null){
// throw exception(DEVICE_DOES_NOT_EXIST);
// }
// 设置租户上下文
TenantContextHolder.setTenantId(1L);
LambdaQueryWrapper<DeviceContactModelDO> deviceModelAttributeLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceModelAttributeLambdaQueryWrapper.eq(DeviceContactModelDO::getDeviceId,deviceId);
List<DeviceContactModelDO> deviceContactModelDOS = deviceContactModelMapper.selectList(deviceModelAttributeLambdaQueryWrapper);
if (deviceContactModelDOS != null && deviceContactModelDOS.size() > 0){
for (DeviceContactModelDO deviceContactModelDO : deviceContactModelDOS) {
Object addressValue = OpcUtils.readValue(deviceContactModelDO.getAddress() != null ? deviceContactModelDO.getAddress() : "");
deviceContactModelDO.setAddressValue(addressValue);
}
}
String json = JSON.toJSONString(deviceContactModelDOS);
tDengineService.insertDeviceData(deviceId,json);
// // 设置租户上下文
// TenantContextHolder.setTenantId(1L);
//
// LambdaQueryWrapper<DeviceContactModelDO> deviceModelAttributeLambdaQueryWrapper = new LambdaQueryWrapper<>();
// deviceModelAttributeLambdaQueryWrapper.eq(DeviceContactModelDO::getDeviceId,deviceId);
// List<DeviceContactModelDO> deviceContactModelDOS = deviceContactModelMapper.selectList(deviceModelAttributeLambdaQueryWrapper);
//
// if (deviceContactModelDOS != null && deviceContactModelDOS.size() > 0){
// for (DeviceContactModelDO deviceContactModelDO : deviceContactModelDOS) {
// Object addressValue = OpcUtils.readValue(deviceContactModelDO.getAddress() != null ? deviceContactModelDO.getAddress() : "");
// deviceContactModelDO.setAddressValue(addressValue);
// }
//
// }
// String json = JSON.toJSONString(deviceContactModelDOS);
// tDengineService.insertDeviceData(deviceId,json);
return "";
}

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.mes.controller.admin.deviceledger.vo;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
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.ticketresults.TicketResultsDO;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.TableField;
@ -10,6 +12,7 @@ import lombok.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import com.alibaba.excel.annotation.*;
import org.springframework.format.annotation.DateTimeFormat;
@ -112,6 +115,11 @@ public class DeviceLedgerRespVO extends BaseDO {
@Schema(description = "保养结果列表")
private List<TicketResultsDO> maintainList;
@Schema(description = "维修列表")
private Map<String,List<DvRepairLineDO>> repairList;
;
@Schema(description = "关键件列表")
private List<CriticalComponentDO> componentList;
@Schema(description = "附件地址")
@ExcelProperty("附件地址")

@ -100,9 +100,24 @@ public class DvRepairController {
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<DvRepairDO> list = dvRepairService.getDvRepairPage(pageReqVO).getList();
List<DvRepairRespVO> dvRepairRespVOList = BeanUtils.toBean(list, DvRepairRespVO.class);
for (DvRepairRespVO dvSubjectRespVO : dvRepairRespVOList) {
if (dvSubjectRespVO.getAcceptedBy() !=null) {
AdminUserRespDTO user = adminUserApi.getUser(Long.valueOf(dvSubjectRespVO.getAcceptedBy()));
dvSubjectRespVO.setAcceptedBy("(" + user.getUsername() + ")" + user.getNickname());
}
if (dvSubjectRespVO.getConfirmBy() !=null) {
AdminUserRespDTO user = adminUserApi.getUser(Long.valueOf(dvSubjectRespVO.getConfirmBy()));
dvSubjectRespVO.setConfirmBy("(" + user.getUsername() + ")" + user.getNickname());
}
if (dvSubjectRespVO.getStatus() !=null) {
dvSubjectRespVO.setStatusName(dvSubjectRespVO.getStatus() != null ?
(dvSubjectRespVO.getStatus() == 0 ? "待完成" : "已完成") : null);
}
}
// 导出 Excel
ExcelUtils.write(response, "设备维修记录.xls", "数据", DvRepairRespVO.class,
BeanUtils.toBean(list, DvRepairRespVO.class));
ExcelUtils.write(response, "设备维修记录.xls", "数据", DvRepairRespVO.class,dvRepairRespVOList);
}
// ==================== 子表(设备维修记录行) ====================

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.mes.controller.admin.dvrepair.vo;
import cn.iocoder.yudao.module.mes.controller.admin.dvrepair.enums.MoldRecordStatusEnum;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -55,14 +56,17 @@ public class DvRepairRespVO {
@Schema(description = "报修日期")
@ExcelProperty("报修日期")
@ColumnWidth(20)
private LocalDateTime requireDate;
@Schema(description = "完成日期")
@ExcelProperty("完成日期")
@ColumnWidth(20)
private LocalDateTime finishDate;
@Schema(description = "验收日期")
@ExcelProperty("验收日期")
@ColumnWidth(20)
private LocalDateTime confirmDate;
@Schema(description = "维修结果")
@ -78,9 +82,14 @@ public class DvRepairRespVO {
private String confirmBy;
@Schema(description = "单据状态", example = "1")
@ExcelProperty(value = "单据状态 0-待完成 1-已完成", converter = DictConvert.class)
@ExcelProperty(value = "单据状态 0-待完成 1-已完成")
@DictFormat("mes_mold_record_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private MoldRecordStatusEnum status;
private Integer status;
@Schema(description = "单据状态", example = "1")
@ExcelProperty(value = "单据状态 0-待完成 1-已完成")
@DictFormat("mes_mold_record_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String statusName;
@Schema(description = "备注", example = "你猜")
@ExcelProperty("备注")
@ -88,6 +97,7 @@ public class DvRepairRespVO {
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
@ColumnWidth(20)
private LocalDateTime createTime;
@Schema(description = "设备类型 1-设备 2-关键件", example = "你猜")

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.mes.controller.admin.repairtems;
import cn.iocoder.yudao.module.mes.dal.dataobject.criticalcomponent.CriticalComponentDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@ -108,13 +110,24 @@ public class RepairTemsController {
@GetMapping("/getDeviceOrComponentList")
@Operation(summary = "获得设备/关键件列表")
@Parameter(name = "deviceType", description = "deviceType 1-设备 2-关键件", required = true, example = "1024")
// @Parameter(name = "deviceType", description = "deviceType 1-设备 2-关键件", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('mes:repair-tems:query')")
public CommonResult<List<RepairTemsRespVO>> getDeviceOrComponentList(
@Parameter(name = "deviceId", description = "设备Id", required = true, example = "123")
@RequestParam("deviceId") Long deviceId,
@Parameter(name = "componentId", description = "关键件Id", required = true, example = "123")
@RequestParam("componentId") Long componentId) {
@Parameter(name = "componentId", description = "关键件Id", required = false, example = "123")
@RequestParam(value = "componentId",required = false) Long componentId) {
return success(repairTemsService.getDeviceOrComponentList(deviceId,componentId));
}
@GetMapping("/getComponentList")
@Operation(summary = "获得设备关键件")
@Parameter(name = "deviceId", description = "deviceId设备Id", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('mes:repair-tems:query')")
public CommonResult<List<CriticalComponentDO>> getComponentList(@RequestParam("deviceId") Long deviceId) {
return success( repairTemsService.getComponentList(deviceId));
}
}

@ -0,0 +1,67 @@
package cn.iocoder.yudao.module.mes.controller.admin.repairtems.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.LinkedHashMap;
import java.util.Map;
/**
*
*/
@Getter
@AllArgsConstructor
@Schema(description = "设备类型枚举")
public enum DeviceTypeEnum {
DEVICE(1, "设备"),
CRITICAL_COMPONENT(2, "关键件");
@Schema(description = "类型", example = "1")
private final Integer type;
@Schema(description = "描述", example = "设备")
private final String description;
/**
*
*/
public static DeviceTypeEnum getByType(Integer type) {
if (type == null) {
return null;
}
for (DeviceTypeEnum deviceType : DeviceTypeEnum.values()) {
if (deviceType.getType().equals(type)) {
return deviceType;
}
}
return null;
}
/**
*
*/
public static String getDescriptionByType(Integer type) {
DeviceTypeEnum deviceType = getByType(type);
return deviceType != null ? deviceType.getDescription() : "未知";
}
/**
*
*/
public static boolean isValid(Integer type) {
return getByType(type) != null;
}
/**
*
*/
public static Map<Integer, String> getAllTypes() {
Map<Integer, String> map = new LinkedHashMap<>();
for (DeviceTypeEnum deviceType : values()) {
map.put(deviceType.getType(), deviceType.getDescription());
}
return map;
}
}

@ -50,4 +50,6 @@ public class RepairTemsPageReqVO extends PageParam {
@Schema(description = "项目内容")
private String projectContent;
@Schema(description = "id集合导出用")
private String ids;
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.mes.controller.admin.repairtems.vo;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -25,27 +26,30 @@ public class RepairTemsRespVO {
private String subjectName;
@Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("设备类型")
private Integer deviceType;
@Schema(description = "设备类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("项目名称")
private String deviceTypeName;
@Schema(description = "设备id", example = "11632")
@ExcelProperty("设备id")
// @ExcelProperty("设备id")
private Long deviceId;
@Schema(description = "关键件id", example = "29557")
@ExcelProperty("关键件id")
// @ExcelProperty("关键件id")
private Long componentId;
@Schema(description = "检验方式")
@ExcelProperty("检验方式")
// @ExcelProperty("检验方式")
private String inspectionMethod;
@Schema(description = "值类型", example = "1")
@ExcelProperty("值类型")
// @ExcelProperty("值类型")
private String valueType;
@Schema(description = "判定基准")
@ExcelProperty("判定基准")
// @ExcelProperty("判定基准")
private String judgmentCriteria;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@ -60,14 +64,13 @@ public class RepairTemsRespVO {
@ExcelProperty("设备名称")
private String deviceName;
@Schema(description = "关键件名称")
@ExcelProperty("关键件名称")
private String componentName;
@Schema(description = "创建人名称")
@ExcelProperty("创建人名称")
private String creatroName;
private String creatorName;
@Schema(description = "项目内容")
@ExcelProperty("项目内容")

@ -23,7 +23,7 @@ public class RepairTemsSaveReqVO {
@Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "设备类型不能为空")
private Boolean deviceType;
private Integer deviceType;
@Schema(description = "设备id", example = "11632")
private Long deviceId;

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger;
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.ticketresults.TicketResultsDO;
import lombok.*;
@ -126,4 +127,10 @@ public class DeviceLedgerDO extends BaseDO {
@TableField(exist = false)
private Map<String,List<DvRepairLineDO>> repairList;
/**
*
*/
@TableField(exist = false)
private List<CriticalComponentDO> componentList;
}

@ -2,14 +2,17 @@ package cn.iocoder.yudao.module.mes.service.deviceledger;
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.dal.dataobject.criticalcomponent.CriticalComponentDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.dvrepair.DvRepairDO;
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.mysql.criticalcomponent.CriticalComponentMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.dvrepair.DvRepairLineMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.dvrepair.DvRepairMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.ticketresults.TicketResultsMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -17,6 +20,8 @@ import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import java.util.stream.Collectors;
import cn.iocoder.yudao.module.mes.controller.admin.deviceledger.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -50,6 +55,8 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
@Resource
private DvRepairMapper dvRepairMapperRepair;
@Resource
private CriticalComponentMapper criticalComponentMapper;
@Override
public Long createDeviceLedger(DeviceLedgerSaveReqVO createReqVO) {
@ -116,17 +123,20 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
DeviceLedgerDO deviceLedgerDO = deviceLedgerMapper.selectById(id);
Map<String,List<DvRepairLineDO>> dvRepairDOMap=new HashMap<>();
//点检列表
List<TicketResultsDO> inspectionList = ticketResultsMapper.findByDeviceIdAndPlanType(id, PlanTypeEnum.INSPECTION.getCode());
if(CollectionUtils.isNotEmpty(inspectionList)){
deviceLedgerDO.setInspectionList(inspectionList);
}
//保养列表
List<TicketResultsDO> maintainList = ticketResultsMapper.findByDeviceIdAndPlanType(id, PlanTypeEnum.MAINTENANCE.getCode());
if(CollectionUtils.isNotEmpty(maintainList)){
deviceLedgerDO.setMaintainList(maintainList);
}
//维修列表
List<DvRepairDO> dvRepairDOS = dvRepairMapperRepair.selectList(
Wrappers.<DvRepairDO>lambdaQuery()
.eq(DvRepairDO::getDeviceId, id));
@ -135,7 +145,9 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
List<DvRepairLineDO> dvRepairLineDOS = dvRepairLineMapper.selectList(Wrappers.<DvRepairLineDO>lambdaQuery()
.eq(DvRepairLineDO::getRepairId, dvRepairDO.getId())
.orderByDesc(DvRepairLineDO::getCreateTime));
dvRepairDOMap.put(dvRepairDO.getRepairName(),dvRepairLineDOS);
if (!dvRepairLineDOS.isEmpty()) {
dvRepairDOMap.put(dvRepairDO.getRepairName(), dvRepairLineDOS);
}
}
if(CollectionUtils.isNotEmpty(dvRepairDOMap)){
@ -143,6 +155,26 @@ public class DeviceLedgerServiceImpl implements DeviceLedgerService {
}
//关键件列表
List<CriticalComponentDO> componentList = new ArrayList<>();
if (StringUtils.isNotBlank(deviceLedgerDO.getComponentId())) {
// 将逗号分隔的字符串转换为Long类型的List
List<Long> idList = Arrays.stream(deviceLedgerDO.getComponentId().split(","))
.map(String::trim) // 去除可能存在的空格
.map(Long::valueOf)
.collect(Collectors.toList());
for (Long componentId : idList) {
CriticalComponentDO criticalComponentDO = criticalComponentMapper.selectById(componentId);
if(criticalComponentDO!=null){
componentList.add(criticalComponentDO);
}
}
deviceLedgerDO.setComponentList(componentList);
}
return deviceLedgerDO;
}

@ -67,7 +67,7 @@ public class DvRepairServiceImpl implements DvRepairService {
//编码重复判断
Long count = dvRepairMapper.selectCount(new LambdaQueryWrapper<DvRepairDO>()
.eq(DvRepairDO::getRepairCode, updateReqVO.getRepairCode())
.ne(DvRepairDO::getId, updateReqVO.getRepairCode())
.ne(DvRepairDO::getId, updateReqVO.getId())
);

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.mes.service.repairtems;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.mes.controller.admin.repairtems.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.criticalcomponent.CriticalComponentDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.repairtems.RepairTemsDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@ -55,4 +57,6 @@ public interface RepairTemsService {
List<RepairTemsRespVO> getDeviceOrComponent(Integer deviceType);
List<RepairTemsRespVO> getDeviceOrComponentList(Long deviceId, Long componentId);
List<CriticalComponentDO> getComponentList(Long deviceId);
}

@ -2,9 +2,14 @@ package cn.iocoder.yudao.module.mes.service.repairtems;
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.LineDeviceRespVO;
import cn.iocoder.yudao.module.iot.dal.dataobject.devicemodel.DeviceModelDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.criticalcomponent.CriticalComponentDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.deviceledger.DeviceLedgerDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.devicetype.DeviceTypeDO;
import cn.iocoder.yudao.module.mes.dal.mysql.criticalcomponent.CriticalComponentMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.deviceledger.DeviceLedgerMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -12,6 +17,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import cn.iocoder.yudao.module.mes.controller.admin.repairtems.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.repairtems.RepairTemsDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -36,6 +43,12 @@ public class RepairTemsServiceImpl implements RepairTemsService {
@Resource
private RepairTemsMapper repairTemsMapper;
@Resource
private DeviceLedgerMapper deviceLedgerMapper;
@Resource
private CriticalComponentMapper criticalComponentMapper;
@Override
public Long createRepairTems(RepairTemsSaveReqVO createReqVO) {
//编码重复判断
@ -115,4 +128,32 @@ public class RepairTemsServiceImpl implements RepairTemsService {
return repairTemsMapper.getRepairTemsList(new RepairTemsPageReqVO().setDeviceId(deviceId).setComponentId(componentId));
}
@Override
public List<CriticalComponentDO> getComponentList(Long deviceId) {
DeviceLedgerDO deviceLedgerDO = deviceLedgerMapper.selectById(deviceId);
if(deviceLedgerDO == null ){
throw exception(DEVICE_LEDGER_NOT_EXISTS);
}
if (StringUtils.isBlank(deviceLedgerDO.getComponentId())){
return new ArrayList<>();
}
List<CriticalComponentDO> criticalComponentDOS= new ArrayList<>();
List<Long> idList = Arrays.stream(deviceLedgerDO.getComponentId().split(","))
.map(String::trim) // 去除可能存在的空格
.map(Long::valueOf)
.collect(Collectors.toList());
for (Long id : idList) {
CriticalComponentDO criticalComponentDO = criticalComponentMapper.selectById(id);
if (criticalComponentDO !=null){
criticalComponentDOS.add(criticalComponentDO);
}
}
return criticalComponentDOS;
}
}

@ -18,6 +18,11 @@
mrt.subject_code,
mrt.subject_name,
mrt.device_type,
CASE
WHEN mrt.device_type = 1 THEN '设备'
WHEN mrt.device_type = 2 THEN '关键件'
ELSE '未知'
END AS deviceTypeName,
mrt.device_id,
mrt.component_id,
mrt.inspection_method,
@ -30,15 +35,16 @@
mrt.update_time,
mrt.deleted,
mrt.tenant_id,
mds.subject_name as deviceName,
mrt.project_content,
mdl.device_name as deviceName,
mcc.name as componentName,
CONCAT('(', su.username, ')', su.nickname) as creatorName
FROM besure.mes_repair_tems mrt
left join besure.mes_dv_subject mds on mds.id = mrt.device_id
left join besure.mes_device_ledger mdl on mdl.id = mrt.device_id
left join besure.mes_critical_component mcc on mcc.id = mrt.component_id
left join besure.system_users su on su.id = mrt.creator
WHERE mrt.deleted = 0
order by mrt.create_time desc
WHERE 1=1
AND mrt.deleted = 0
<if test="pageReqVO.subjectCode != null and pageReqVO.subjectCode != ''">
AND mrt.subject_code = #{pageReqVO.subjectCode}
</if>
@ -70,12 +76,13 @@
<if test="pageReqVO.projectContent != null and pageReqVO.projectContent != ''">
AND mrt.project_content LIKE CONCAT('%', #{pageReqVO.projectContent}, '%')
</if>
<!-- 添加 ids 过滤条件 -->
<if test="pageReqVO.ids != null and pageReqVO.ids != ''">
AND FIND_IN_SET(mrt.id, #{pageReqVO.ids})
</if>
<!-- <if test="pageReqVO.createTime != null and pageReqVO.createTime.length == 2">-->
<!-- AND create_time BETWEEN #{pageReqVO.createTime[0]} AND #{pageReqVO.createTime[1]}-->
<!-- </if>-->
ORDER BY mrt.create_time DESC
</select>
<select id="getRepairTemsList"
resultType="cn.iocoder.yudao.module.mes.controller.admin.repairtems.vo.RepairTemsRespVO">
@ -96,15 +103,14 @@
mrt.update_time,
mrt.deleted,
mrt.tenant_id,
mds.subject_name as deviceName,
mdl.device_name as deviceName,
mcc.name as componentName,
CONCAT('(', su.username, ')', su.nickname) as creatorName
FROM besure.mes_repair_tems mrt
left join besure.mes_dv_subject mds on mds.id = mrt.device_id
left join besure.mes_device_ledger mdl on mdl.id = mrt.device_id
left join besure.mes_critical_component mcc on mcc.id = mrt.component_id
left join besure.system_users su on su.id = mrt.creator
WHERE mrt.deleted = 0
order by mrt.create_time desc
<if test="pageReqVO.subjectCode != null and pageReqVO.subjectCode != ''">
AND mrt.subject_code = #{pageReqVO.subjectCode}
</if>
@ -136,9 +142,12 @@
<if test="pageReqVO.projectContent != null and pageReqVO.projectContent != ''">
AND mrt.project_content LIKE CONCAT('%', #{pageReqVO.projectContent}, '%')
</if>
<!-- 添加 ids 过滤条件 -->
<if test="pageReqVO.ids != null and pageReqVO.ids != ''">
AND FIND_IN_SET(mrt.id, #{pageReqVO.ids})
</if>
<!-- <if test="pageReqVO.createTime != null and pageReqVO.createTime.length == 2">-->
<!-- AND create_time BETWEEN #{pageReqVO.createTime[0]} AND #{pageReqVO.createTime[1]}-->
<!-- </if>-->
ORDER BY mrt.create_time DESC
</select>
</mapper>
Loading…
Cancel
Save