getMachineType

本文介绍了一段TCL脚本代码,该脚本用于获取当前运行环境的机器类型。通过检查环境变量并调用uname命令来识别操作系统类型及架构,支持包括Linux x86_64、i686等架构。
 proc getMachineType { } {
       global env
  
       if {[info exists env(OS)]} {
    return nt
       } else {
    set os [exec uname]
    switch -exact -- $os {
        OSF1   { return decunix }
        IRIX64 { return irix }
        Linux {
     set mach [exec uname -m]
     switch -exact -- $mach {
         i686 { return linux }
         x86_64 { return linux64 }
         ia64 { return ia64 }
     }
        }
    }
       }
       ### reach here, unknown machine
       puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
       puts "Unknow MACHINE, please edit bluice.tcl to find right MACHINE!!"
       puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  
       return ""
   }

转载于:https://www.cnblogs.com/greencolor/archive/2011/05/20/2052353.html

//根据参数计算工时 public float getNonStdPartProTimeByMap(Map<String,String> paramMap) { try { OrderInfoDm orderInfoDm = buildOrderInfoDm(paramMap); //机床类型判断(非标车床、非标磨床、铣床/高频机) orderInfoDm.setMachineType(getMachineTypeByNo(orderInfoDm.getMachineNo())); float workTime; if("车床".equals(orderInfoDm.getMachineType())){ workTime = getNonStdLatheTime(orderInfoDm); }else if("磨床".equals(orderInfoDm.getMachineType())){ workTime = getNonStdGrindingTime(orderInfoDm); }else if("铣床".equals(orderInfoDm.getMachineType()) || "高频机".equals(orderInfoDm.getMachineType())){ workTime = getNonStdMillingTime(orderInfoDm); }else { workTime = 0f; logger.warning("机床类型获取失败:" + orderInfoDm.getMachineNo()); // throw new EJBException("机床类型获取失败"); } return workTime; }catch (Exception e){ String msg = ExceptionUtils.getRootCauseMessage(e); logger.warning(msg); throw new EJBException(msg); } } //根据参数返回详情 public OrderInfoDm getNonStdPartProDetailByMap(Map<String,String> paramMap) { try { //组装信息 OrderInfoDm orderInfoDm = buildOrderInfoDm(paramMap); //机床类型判断(非标车床、非标磨床、铣床/高频机) orderInfoDm.setMachineType(getMachineTypeByNo(orderInfoDm.getMachineNo())); if("车床".equals(orderInfoDm.getMachineType())){ orderInfoDm = getNonStdLatheDm(orderInfoDm); }else if("磨床".equals(orderInfoDm.getMachineType())){ orderInfoDm = getNonStdGrindingDm(orderInfoDm); }else if("铣床".equals(orderInfoDm.getMachineType()) || "高频机".equals(orderInfoDm.getMachineType())){ orderInfoDm = getNonStdMillingDm(orderInfoDm); }else { return null; logger.warning("机床类型获取失败:" + orderInfoDm.getMachineNo()); // throw new EJBException("机床类型获取失败"); } return orderInfoDm; }catch (Exception e){ String msg = ExceptionUtils.getRootCauseMessage(e); logger.warning(msg); throw new EJBException(msg); } } //非标车床计算总工时 private float getNonStdLatheTime(OrderInfoDm dm) { //获取定值 dm.setWorkTime(getLatheBaseTime(dm)); //成形工序要按公式计算并不是最终定值,二次计算重新赋值 if("成形".equals(dm.getProcessName())) { dm = LatheTimeUtils.getLastWorkTime(dm); } //非标车床附加工时 dm.setOtherWorkTime(LatheTimeUtils.getOtherTime(dm)); //调整系数 dm.setRatio(LatheTimeUtils.getProcessRatio(dm)); //钢种系数 dm.setSteelRatio(1f); //机床系数 dm.setMachineRatio(1f); //计算总工时 float totalTime = calculateTotalTime(dm); dm.setTotalWorkTime(totalTime); logger.info("车床工时信息:" + dm.toString()); return totalTime; } //非标车床返回信息 private OrderInfoDm getNonStdLatheDm(OrderInfoDm dm) { //获取定值 dm.setWorkTime(getLatheBaseTime(dm)); //成形工序要按公式计算并不是最终定值,二次计算重新赋值 if("成形".equals(dm.getProcessName())) { dm = LatheTimeUtils.getLastWorkTime(dm); } //非标车床附加工时 dm.setOtherWorkTime(LatheTimeUtils.getOtherTime(dm)); //调整系数 dm.setRatio(LatheTimeUtils.getProcessRatio(dm)); //钢种系数 dm.setSteelRatio(1f); //机床系数 dm.setMachineRatio(1f); //计算总工时 dm.setTotalWorkTime(calculateTotalTime(dm)); return dm; }怎么优化好 不要难懂的
08-07
package com.ruoyi.project.business.service.impl; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.project.business.domain.*; import com.ruoyi.project.business.mapper.*; import com.ruoyi.project.business.service.ICheckPlanService; import com.ruoyi.project.system.domain.MLine; import com.ruoyi.project.system.mapper.MLineMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.DayOfWeek; import java.time.LocalDate; import java.util.ArrayList; import java.util.Date; import java.util.List; @Service public class CheckPlanService implements ICheckPlanService { @Autowired private MLineMapper lineMapper; @Autowired private MachinemodelMapper machinemodelMapper; @Autowired private MachineVoMapper machineVoMapper; @Autowired private MachineCheckBindingMapper machineCheckBindingMapper; @Autowired private InspectionTemplateMapper inspectionTemplateMapper; @Autowired private InspectionTemplateItemMapper inspectionTemplateItemMapper; @Autowired private CheckTaskMapper checkTaskMapper; @Autowired private CheckTaskItemMapper checkTaskItemMapper; @Autowired EmsSysWorkShopMapper emsSysWorkShopMapper; public static final Logger log = LoggerFactory.getLogger(CheckPlanService.class); @Override @Transactional public AjaxResult machineCheckByLine(Long lineId) { try { //1. 获取线体信息(包括当前机种ID) MLine line = lineMapper.selectMLineById(lineId); if (line == null || line.getModelId() == null) { return AjaxResult.error("线体不存在或未设置机种"); } Long modelId = line.getModelId(); // 2. 获取机种信息 Machinemodel machinemodel = machinemodelMapper.selectMachinemodelById(modelId); if (machinemodel == null) { return AjaxResult.error("机种不存在"); } //3. 根据线体ID获取该线体下的所有设备 List<MachineVo> machineVoList = machineVoMapper.selectMachineByLineId(lineId); if (machineVoList == null || machineVoList.isEmpty()) { return AjaxResult.error("当前线体下没有设备"); } //4. 对于每个设备,根据设备ID和线体的当前机种ID,查找设备绑定的点检模板 List<MachineCheckTaskDTO> taskDTOList = new ArrayList<>(); int generatedTaskCount = 0; for (MachineVo machine : machineVoList) { // 根据设备ID和机种ID获取绑定的模板 List<MachineCheckBinding> bindings = machineCheckBindingMapper.selectByMachineAndModel(machine.getId(),modelId); if (bindings == null || bindings.isEmpty()) { continue; // 该设备没有绑定模板 } // 遍历所有绑定关系 for (MachineCheckBinding binding : bindings) { // 获取模板信息 InspectionTemplate template = inspectionTemplateMapper.selectInspectionTemplateById(binding.getTemplateId()); if (template == null || !"1".equals(template.getStatus().toString())) { continue; // 模板不存在或未启用 } // 获取模板下的所有点检项 InspectionTemplateItem inspectionTemplateItem = new InspectionTemplateItem(); inspectionTemplateItem.setCheckTemplateId(binding.getTemplateId()); List<InspectionTemplateItem> templateItems = inspectionTemplateItemMapper.selectInspectionTemplateItemList(inspectionTemplateItem); if (templateItems == null || templateItems.isEmpty()) { continue; } // 筛选今日需要生成的点检项 List<InspectionTemplateItem> todayItems = new ArrayList<>(); for (InspectionTemplateItem item : templateItems) { if (shouldGenerateToday(item.getCycleType())) { todayItems.add(item); } } if (!todayItems.isEmpty()) { // 创建任务DTO MachineCheckTaskDTO taskDTO = new MachineCheckTaskDTO(); taskDTO.setMachine(machine); taskDTO.setTemplate(template); taskDTO.setTemplateItems(todayItems); taskDTOList.add(taskDTO); // 生成点检任务和任务项 generateCheckTask(machine, line, machinemodel, template, todayItems); generatedTaskCount++; } } } if (generatedTaskCount == 0) { return AjaxResult.success("没有需要生成的点检任务"); } return AjaxResult.success("成功生成" + generatedTaskCount + "个点检任务"); } catch (Exception e) { log.error("生成点检任务失败: {}", e.getMessage()); return AjaxResult.error("生成点检任务失败: " + e.getMessage()); } } /** * 判断今天是否需要生成点检项 */ private boolean shouldGenerateToday(String cycleType) { if (StringUtils.isEmpty(cycleType)) { return false; } LocalDate today = LocalDate.now(); switch (cycleType) { case "日检": return true; case "周检": return today.getDayOfWeek() == DayOfWeek.MONDAY; case "月检": return today.getDayOfMonth() == 1; case "年检": return today.getMonthValue() == 1 && today.getDayOfMonth() == 1; default: return false; } } /** * 生成点检任务和任务项 */ private void generateCheckTask(MachineVo machine, MLine line, Machinemodel machinemodel, InspectionTemplate template, List<InspectionTemplateItem> templateItems) { // 创建点检任务 CheckTask checkTask = new CheckTask(); checkTask.setLineId(line.getLineId()); checkTask.setLineName(line.getLineName()); checkTask.setMachineId(machine.getId()); checkTask.setMachineName(machine.getDeviceName()); checkTask.setMachineCode(machine.getCustodyNo()); checkTask.setModelId(machinemodel.getId()); checkTask.setModelName(machinemodel.getModel()); checkTask.setCheckTemplateId(template.getCheckTemplateId()); checkTask.setCheckTemplateName(template.getCheckTemplateName()); checkTask.setStatus(0); // 未完成 checkTask.setCreateTime(new Date()); checkTask.setCreateBy(SecurityUtils.getUsername()); // 获取当前登录用户 // 设置车间信息(根据实际情况调整) if (line.getShopId() != null) { EmsSysWorkShop emsSysWorkShop = emsSysWorkShopMapper.selectWorkShopByShopId(line.getShopId()); checkTask.setWorkshopId(emsSysWorkShop.getId()); checkTask.setWorkshopName(emsSysWorkShop.getWorkshopName()); } // 插入点检任务 checkTaskMapper.insertCheckTask(checkTask); // 生成点检任务项 for (InspectionTemplateItem templateItem : templateItems) { CheckTaskItem taskItem = new CheckTaskItem(); taskItem.setCheckTaskId(checkTask.getCheckTaskId()); taskItem.setCheckTemplateItemId(templateItem.getCheckTemplateItemId()); taskItem.setCheckTemplateItemName(templateItem.getCheckTemplateItemName()); taskItem.setStandard(templateItem.getStandard()); taskItem.setMaximums(templateItem.getMaximums()); taskItem.setMinimums(templateItem.getMinimums()); taskItem.setMethod(templateItem.getMethod()); taskItem.setTestMachine(templateItem.getTestMachine()); taskItem.setPersona(templateItem.getPersona()); taskItem.setCycleType(templateItem.getCycleType()); taskItem.setShiftCode(templateItem.getShiftCodes()); taskItem.setCycle(templateItem.getCycle()); taskItem.setManHour(templateItem.getManHour()); taskItem.setCreateTime(new Date()); taskItem.setCreateBy(SecurityUtils.getUsername()); // 获取当前登录用户 // 插入点检任务项 checkTaskItemMapper.insertCheckTaskItem(taskItem); } } } 帮我优化上述的代码我在上述代码中通过设备ID获取对应机种模板绑定信息时,一共为五台设备,其中有一天符合绑定条件要进行点检任务生成但是遍历后面四台设备不符合直接返回了,是否可以先做匹配如果匹配了,单独存入一个List集合中 单独遍历所匹配的设备进行点检任务生成 { "msg": "没有需要生成的点检任务", "code": 200 } 一下是我代码的全部运行日志 15:54:08.964 [http-nio-9091-exec-1] INFO o.a.c.c.C.[.[.[/] - [log,173] - Initializing Spring DispatcherServlet 'dispatcherServlet' 15:54:09.137 [http-nio-9091-exec-1] DEBUG c.r.p.s.m.M.selectMLineById - [debug,137] - ==> Preparing: SELECT a.id, a.line, a.plantid, b.dept_name AS plant_name, a.deleteflag, a.creatorid, a.createtime, a.updaterid, a.updatetime, a.code, a.area_id, c.area_name AS area, a.lineeng, a.remark, a.status, a.model_id, d.model AS model_name, a.shop_id, e.WORKSHOP_NAME as shop_name, a.RESPONSIBLE_PERSONS FROM tpmdata.line a LEFT JOIN tpmapp.sys_dept b ON a.plantid = b.dept_id LEFT JOIN tpmdata.m_area c ON a.area_id = c.area_id LEFT JOIN tpmdata.machinemodel d ON a.model_id = d.id LEFT JOIN tpmdata.EMS_SYS_WORKSHOP e ON a.shop_id = e.id where a.id = ? 15:54:09.140 [http-nio-9091-exec-1] DEBUG c.r.p.s.m.M.selectMLineById - [debug,137] - ==> Parameters: 951(Long) 15:54:09.144 [http-nio-9091-exec-1] DEBUG c.r.p.s.m.M.selectMLineById - [debug,137] - <== Total: 1 15:54:09.145 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectMachinemodelById - [debug,137] - ==> Preparing: SELECT a.id, a.model, a.creatorid, b.employee_name AS create_name, a.createtime, a.updaterid, c.employee_name AS update_name, a.updatetime, a.note, a.deleteflag, a.plantid, d.dept_name AS plant_name, a.process, a.rated_UPH FROM tpmdata.machinemodel a LEFT JOIN tpmdata.sap_employee b ON a.creatorid = b.employee_no LEFT JOIN tpmdata.sap_employee c ON a.updaterid = c.employee_no LEFT JOIN tpmapp.sys_dept d ON a.plantid = d.dept_id where id = ? 15:54:09.145 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectMachinemodelById - [debug,137] - ==> Parameters: 11991(Long) 15:54:09.149 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectMachinemodelById - [debug,137] - <== Total: 1 15:54:09.150 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectMachineByLineId - [debug,137] - ==> Preparing: SELECT DISTINCT A.ID, A.TYPE, A.PLANTID, N.DEPT_NAME AS PLANT_NAME, A.APN, H.STATUS AS STORAGE_NAME, A.LOCATION, K.STORENAME AS LOCATION_NAME, A.LINEID, D.LINE AS LINE_NAME, A.SERIALNO, A.CUSTODYNO, A.AMORTIZATIONYEAR, A.PURCHASEDATE, A.MESID, A.STANCE, A.CUSTODYDEPTID, E.ORG_NAME AS CUSTODYDEPT_NAME, A.CUSTODYPEOPLEID, E.EMPLOYEE_NAME AS CUSTODYPEOPLE_NAME, A.USECOUNT, A.DEPRECIATIONRATE, A.REMARK, A.COSTATTRIBUTES, A.STATUSID, I.STATUS AS STATUS_NAME, A.STORELOCATION, A.LINEORDER, A.PARTNO, A.CLASSID, F.CLASSNAME AS CLASS_NAME, A.MODELID, G.MODEL AS MODEL_NAME, A.DEVICENAME, A.STORELOCATIONCODE, J.DEPTEMP AS STORELOCATION_NAME, A.ITEM_NO, A.MAINTENANCEPEOPLEDEPARTMENTID, T.ORG_NAME AS MAINTENANCEPEOPLEDEPARTMENT, A.REQ_MAINTENANCE_TIME, A.ASSESTNO, A.RESPONSIBLE_PERSON, A.RESPONSIBLE_DEPT, A.DEVICE_RANGE, A.CREATORID, B.EMPLOYEE_NAME AS CREATOR_NAME, A.CREATETIME, A.UPDATERID, C.EMPLOYEE_NAME AS UPDATER_NAME, A.UPDATETIME, A.PLANNER_GROUP, O.GROUP_NAME AS PLANNER_GROUP_NAME, A.PLANNER_GROUP_STR, A.PLANNER_GROUP_NAME_STR, A.DEFECT_GROUP, P.DEFECT_DESC AS DEFECT_GROUP_NAME, A.STOREID AS STOREID, Q.WAREHOUSE_DESC AS STORE_NAME, A.STORELOCATIONID AS STORELOCATIONID, R.LOCATION_DESC AS STORE_LOCATION_NAME, A.STATION_ID AS STATION_ID, A.INSIGHT_ID, S.STATION_TYPE_DESC AS STATION_NAME, ( CASE WHEN A.R_STATUS = 0 THEN '正常或维修结案' WHEN A.R_STATUS = 1 THEN '叫修' WHEN A.R_STATUS = 2 THEN '起修' WHEN A.R_STATUS = 3 THEN '维修记录' ELSE '报工' END ) AS R_STATUS, ( CASE WHEN A.M_STATUS = 0 THEN '正常或保养完成' WHEN A.M_STATUS = 1 THEN '产生保养单' ELSE '启动保养' END ) AS M_STATUS, A.PLATFORM_NUMBER, A.PED_CODE, A.DISABLES_STATUS, A.DISABLES_REMARK, A.PARAGRAPH_ID, V.PARAGRAPH_Name, A.CHECK_TYPE FROM TPMDATA.MACHINE A LEFT JOIN TPMDATA.SAP_EMPLOYEE B ON A.CREATORID = B.EMPLOYEE_NO LEFT JOIN TPMDATA.SAP_EMPLOYEE C ON A.UPDATERID = C.EMPLOYEE_NO LEFT JOIN TPMDATA.LINE D ON A.LINEID = D.ID LEFT JOIN TPMDATA.SAP_EMPLOYEE E ON A.CUSTODYPEOPLEID = E.EMPLOYEE_NO LEFT JOIN TPMDATA.MACHINECLASS F ON A.CLASSID = F.ID LEFT JOIN TPMDATA.MACHINEMODEL G ON A.MODELID = G.ID LEFT JOIN TPMDATA.SAP_DEPARTMENT T ON T.ORG_CODE = A.MAINTENANCEPEOPLEDEPARTMENTID LEFT JOIN TPMDATA.STORAGE_STATUS H ON A.APN = H.ID LEFT JOIN TPMDATA.MACHINESTATUS I ON A.STATUSID = I.ID LEFT JOIN TPMDATA.COST_CENTER J ON A.STORELOCATIONCODE = J.DEPTCODE LEFT JOIN TPMDATA.STORE K ON A.LOCATION = K.STORECODE LEFT JOIN TPMAPP.SYS_DEPT N ON A.PLANTID = N.DEPT_ID LEFT JOIN TPMDATA.group_management O ON A.PLANNER_GROUP = O.GROUP_ID LEFT JOIN TPMDATA.EMS_SYS_DEFECT_GROUP P ON A.DEFECT_GROUP = P.ID LEFT JOIN TPMDATA.M_WAREHOUSE Q ON A.STOREID = Q.WAREHOUSE_ID LEFT JOIN TPMDATA.M_LOCATION R ON A.STORELOCATIONID = R.LOCATION_ID LEFT JOIN TPMDATA.M_STATION_TYPE S ON A.STATION_ID = S.ID LEFT JOIN TPMDATA.m_paragraph V ON V.paragraph_id = A.PARAGRAPH_ID WHERE A.LINEID = ? 15:54:09.151 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectMachineByLineId - [debug,137] - ==> Parameters: 951(Long) 15:54:09.160 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectMachineByLineId - [debug,137] - <== Total: 5 15:54:09.162 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - ==> Preparing: select * from TPMDATA.machine_check_binding WHERE machine_id = ? and model_id = ? 15:54:09.162 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - ==> Parameters: 16296(Long), 11991(Long) 15:54:09.165 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - <== Total: 1 15:54:09.165 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.I.selectInspectionTemplateById - [debug,137] - ==> Preparing: select check_template_id, check_template_name, version, status, create_by, create_time, update_by, update_time, dept_id, delete_flag from tpmdata.inspection_template where check_template_id = ? and delete_flag = 0 15:54:09.166 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.I.selectInspectionTemplateById - [debug,137] - ==> Parameters: 1(Long) 15:54:09.169 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.I.selectInspectionTemplateById - [debug,137] - <== Total: 1 15:54:09.169 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - ==> Parameters: 16457(Long), 11991(Long) 15:54:09.172 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - <== Total: 0 15:54:09.172 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - ==> Parameters: 16456(Long), 11991(Long) 15:54:09.175 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - <== Total: 0 15:54:09.175 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - ==> Parameters: 16277(Long), 11991(Long) 15:54:09.178 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - <== Total: 0 15:54:09.179 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - ==> Parameters: 17825(Long), 11991(Long) 15:54:09.181 [http-nio-9091-exec-1] DEBUG c.r.p.b.m.M.selectByMachineAndModel - [debug,137] - <== Total: 0
08-31
修改完成后,发现 machineType=null, intervalTime=null ,什么原因呢?下方是我的配置信息和代码:# 指定服务的端口 server.port=9200 # 指定服务的名称 spring.application.name=geochance-cxjc # 监测服务操作系统(可选值 win | lin) monitor.machine.type=win # 监测服务时间间隔(可选值 300 | 600) monitor.interval.time=300 # 监测服务名称信息 monitor.servers-list[0].name=auth monitor.servers-list[1].name=system monitor.servers-list[2].name=gateway monitor.servers-list[3].name=ddu monitor.servers-list[4].name=network # 监测服务模式信息(可选值 bash | shell | server) monitor.servers-list[0].mode=bash monitor.servers-list[1].mode=shell monitor.servers-list[2].mode=server monitor.servers-list[3].mode=shell monitor.servers-list[4].mode=server # 监测服务模式信息(可选值 bash | shell | server) monitor.servers-list[0].requrl=127.0.0.1:9201/connect/ monitor.servers-list[1].requrl=127.0.0.1:9202/connect/ monitor.servers-list[2].requrl=127.0.0.1:8080/connect/ monitor.servers-list[3].requrl=127.0.0.1:9203/connect/ monitor.servers-list[4].requrl=127.0.0.1:9203/connect/ package com.geochance.cxjc.config; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.geochance.cxjc.web.domain.ServiceConfig; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; import org.springframework.validation.annotation.Validated; import javax.validation.Valid; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.List; /** * 程序监测配置类 * */ @Data @Validated @Configuration @ConfigurationProperties(prefix = "monitor") // 新增注解解决序列化问题 @JsonIgnoreProperties( value = { "targetSource", // 忽略AOP代理目标源 "$$beanFactory", // 忽略CGLIB生成的beanFactory引用 "advised", // 防止Spring AOP内部状态泄露 "frozen", // 忽略代理配置状态标识 "exposeProxy" // 屏蔽代理暴露标记 }, ignoreUnknown = true // 允许忽略未定义字段 ) public class MonitorConfig { // 操作系统类型校验 @Pattern(regexp = "win|lin", message = "必须为win或lin") private String machineType; // 时间间隔校验 @Min(300) @Max(600) private Integer intervalTime; // 服务列表校验 @Valid @Size(min = 1, message = "至少需要1个服务") private List<ServiceConfig> serversList = new ArrayList<>(); }
03-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值