package com.product.device.service; import com.product.core.config.CoreConst; import com.product.core.dao.BaseDao; import com.product.core.entity.FieldSetEntity; import com.product.core.service.support.AbstractBaseService; import com.product.core.spring.context.SpringMVCContextHolder; import com.product.core.transfer.Transactional; import com.product.device.config.DeviceConst; import com.product.device.service.ide.IDeviceMainenanceService; import com.product.module.sys.entity.SystemUser; import com.product.task.device.service.DeviceManagerTaskService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * 设备维修 * @Author * @Date 2022/3/8 16:33 * @Desc 功能相关 service */ @Service public class DeviceMainenanceService extends AbstractBaseService implements IDeviceMainenanceService { @Autowired public BaseDao baseDao; @Autowired DeviceManagerService deviceManagerService; @Autowired DeviceManagerTaskService deviceManagerTaskService; /** * 获取设备信息 包括子设备 * @param uuid * @param device_sn * @return */ @Transactional public String saveDeviceFailure(FieldSetEntity fs) { SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); if(fs!=null) { fs.setValue("org_level_uuid", currentUser.getOrg_level_uuid()); } fs.setTableName(DeviceConst.TABLE_PRODUCT_REPAIR_FAILURE); boolean b=baseDao.saveFieldSetEntity(fs); if(b) { //修改设备的状态为停机维修 deviceManagerService.deviceStatusChange(fs.getString("asset_code"), "2"); // //上报任务生成 // deviceManagerTaskService.createTask(); //设备运行记录 deviceManagerService.appendDeivceManageLog(fs.getString("asset_code"),fs.getString("created_by"),"","设备故障上报","product_device_repair_failure_record",fs.getString("uuid")); } return fs.getString(CoreConst.UUID); } /** * 创建维修任务,第一次可能选中的是调度人,也可能是维修人员 * @param fs */ public void createMaintainTask(FieldSetEntity fs) { deviceManagerTaskService.createTask(); } }