czt
2025-06-11 283da741b2429cf5a53786e5ee1b5528b757fdf6
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package com.fzzy.igds.dzhwk.manager;
 
import com.fzzy.igds.dzhwk.data.DzhwkConfigData;
import com.fzzy.igds.dzhwk.data.HwkDepotDto;
import com.fzzy.igds.dzhwk.domain.Depot;
import com.fzzy.igds.dzhwk.domain.Dept;
import com.fzzy.igds.dzhwk.domain.Granary;
import com.fzzy.igds.dzhwk.domain.HScreenSer;
import com.fzzy.igds.dzhwk.service.ScreenSerService;
import com.fzzy.igds.file.FileService;
import com.fzzy.igds.gas.dto.GasData;
import com.fzzy.igds.gas.service.GasService;
import com.fzzy.igds.grain.dto.GrainData;
import com.fzzy.igds.grain.service.GrainService;
import com.fzzy.igds.sys.CoreDeptService;
import com.fzzy.igds.sys.DepotService;
import com.fzzy.igds.sys.GranaryService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Description
 * @Author CZT
 * @Date 2025/6/3 16:06
 */
@Slf4j
@Component("WebManager")
public class WebManager {
 
    @Resource
    private CoreDeptService coreDeptService;
    @Resource
    private FileService fileService;
    @Resource
    private DzhwkConfigData dzhwkConfigData;
    @Resource
    private ScreenSerService screenSerService;
    @Resource
    private DepotService depotService;
    @Resource
    private GranaryService granaryService;
    @Resource
    private ISysUserService userService;
    @Resource
    private GrainService grainService;
 
    @Resource
    private GasService gasService;
 
    /**
     * 根据单位ID获取单位信息
     *
     * @param deptId
     * @return
     */
    public Dept getDeptFile(String deptId) {
        if (StringUtils.isEmpty(deptId)) {
            return null;
        }
        Dept dept = coreDeptService.getDataById(deptId);
        dept.setImgFilePath("未上传");
        if (StringUtils.isNotEmpty(dept.getFileId())) {
            String imgBathPath = fileService.getDeptFilePath(dept.getCompanyId()) + dept.getFileId();
            File imgFile = new File(imgBathPath);
            if (imgFile.exists()) {
                imgBathPath = imgBathPath.replace(dzhwkConfigData.getProfile(), "/profile/");
                dept.setImgFilePath(imgBathPath);
            }
        }
 
        dept.setVideoFilePath("未上传");
        if (StringUtils.isNotEmpty(dept.getVideoId())) {
            String imgBathPath = fileService.getDeptFilePath(dept.getCompanyId()) + dept.getVideoId();
            File imgFile = new File(imgBathPath);
            if (imgFile.exists()) {
                imgBathPath = imgBathPath.replace(dzhwkConfigData.getProfile(), "/profile/");
                dept.setVideoFilePath(imgBathPath);
            }
        }
        return dept;
    }
 
    /**
     *
     * @param sid
     * @return
     */
    public List<HwkDepotDto> getDepotsByGid(String sid) {
 
        if(StringUtils.isEmpty(sid)){
            return null;
        }
        //获取sid对应的廒间信息;
        HScreenSer screenSer = screenSerService.getDataBySn(sid);
 
        if(null == screenSer || StringUtils.isEmpty(screenSer.getAjdh())){
            return null;
        }
        Granary granary = granaryService.getGranaryById(screenSer.getAjdh());
        if(null == granary){
            return null;
        }
 
        List<Depot> list = depotService.getCacheByAjdn(screenSer.getCompanyId(), screenSer.getAjdh());
        if(null == list || list.isEmpty()){
            return null;
        }
 
        List<HwkDepotDto> result = new ArrayList<>();
        HwkDepotDto hwkDepotDto;
        for (Depot depot : list) {
            hwkDepotDto = new HwkDepotDto();
            BeanUtils.copyProperties(depot, hwkDepotDto);
 
            hwkDepotDto.setGranaryName(granary.getAjmc());
            hwkDepotDto.setStoreKeeperName(StringUtils.isEmpty(depot.getStoreKeeperName())?"--":depot.getStoreKeeperName());
            hwkDepotDto.setFoodVarietyName(StringUtils.isEmpty(depot.getFoodVarietyName())?"--":depot.getFoodVarietyName());
            hwkDepotDto.setFoodTypeName(StringUtils.isEmpty(depot.getFoodTypeName())?"--":depot.getFoodTypeName());
            hwkDepotDto.setFoodLevelName(StringUtils.isEmpty(depot.getFoodLevelName())?"--":depot.getFoodLevelName());
            hwkDepotDto.setStorageReal(hwkDepotDto.getStorageReal()/1000);
 
            //查询粮情信息
            GrainData grainData = grainService.getCacheGrainDate(depot.getCompanyId(), depot.getId());
            if(null != grainData){
                hwkDepotDto.setInTemp(grainData.getTempIn() + "");
                hwkDepotDto.setInHumidity(grainData.getHumidityIn() + "");
                hwkDepotDto.setOutTemp(grainData.getTempOut() + "");
                hwkDepotDto.setOutHumidity(grainData.getHumidityOut() + "");
                hwkDepotDto.setMaxTemp(grainData.getTempMax() + "");
                hwkDepotDto.setMinTemp(grainData.getTempMin() + "");
                hwkDepotDto.setAveTemp(grainData.getTempAve() + "");
                hwkDepotDto.setGrainDate(grainData.getReceiveDate());
 
            }
 
            //查询气体信息
            GasData gasData = gasService.getCacheGrainDate(depot.getCompanyId(), depot.getId());
            if(null != gasData){
                hwkDepotDto.setPerO2(gasData.getPerO2() + "");
                hwkDepotDto.setPerPh3(gasData.getPerPh3() + "");
                hwkDepotDto.setPerCo2(gasData.getPerCo2() + "");
                hwkDepotDto.setGasDate(gasData.getReceiveDate());
            }
 
            //查询保管员信息
            if(StringUtils.isNotEmpty(depot.getStoreKeeper())){
                SysUser sysUser = userService.selectUserByLoginName(depot.getStoreKeeper());
                hwkDepotDto.setUserImgPath(StringUtils.isEmpty(sysUser.getAvatar())?"/img/dzhwk/imgl6.jpg":sysUser.getAvatar());
                hwkDepotDto.setStoreKeeperPhone(StringUtils.isEmpty(sysUser.getPhonenumber())?"--":sysUser.getPhonenumber());
            }
 
            result.add(hwkDepotDto);
        }
        return result;
    }
}