shichongfu
2023-10-08 6f83c8971714e2384df45706e364ed45a0cd1183
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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();
    }
}