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
package com.product.device.service;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.service.support.AbstractBaseService;
import com.product.device.config.DeviceConst;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.StringUtils;
 
 
/**
 * 设备点检
 * @Author 
 * @Date 2022/3/8 16:33
 * @Desc 功能相关 service
 */
@Service
public class CommonInspectionService extends AbstractBaseService {
 
    @Autowired
    public BaseDao baseDao;
    @Autowired
    DeviceManagerService deviceManagerService;
    /**
     * 获取设备信息 包括子设备
     * @param uuid
     * @param device_sn
     * @return
     */
    public FieldSetEntity createInspection(String device_sn) {
        FieldSetEntity dev=deviceManagerService.findDevice(null,device_sn);
        baseDao.loadPromptData(dev);
        if(dev !=null) {
            DataTableEntity dt=baseDao.listTable(DeviceConst.TABLE_PRODUCT_INSPECT_CONFIG," uuid in( select config_uuid from"+DeviceConst.TABLE_PRODUCT_INSPECT_SETTING_SUB+" where  main_uuid=(select uuid from "+DeviceConst.TABLE_PRODUCT_INSPECT_SETTING+" where device_type=? )", new String[] {dev.getString("device_type")});
            if(!DataTableEntity.isEmpty(dt)) {
                Map <String,DataTableEntity> sub=new HashMap<>();
                sub.put("sub", dt);
                dev.setSubData(sub);
                dev.addSubDataTable(dt);
            }
        }
        return dev;
    }
    
    
}