CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
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
package com.ld.igds.phone.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.grain.manager.GrainManager;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.gas.CoreGasService;
import com.ld.igds.gas.dto.GasData;
import com.ld.igds.gas.dto.GasParam;
import com.ld.igds.phone.constant.PhoneConstant;
import com.ld.igds.phone.dto.AuthUser;
import com.ld.igds.phone.dto.DtoGas;
import com.ld.igds.phone.dto.PhoneResponse;
import com.ld.igds.phone.param.ParamDepot;
import com.ld.igds.phone.param.PhoneRequest;
import com.ld.igds.phone.service.PhoneService;
import com.ld.igds.phone.util.PhoneRespUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * 粮情展示-气体详情接口实现
 *
 * @author chen
 */
@Service
public class ServiceImpl5306 implements PhoneService {
 
    @Autowired
    private CoreGasService coreGasService;
 
    @Override
    public String getInterfaceId() {
        return PhoneConstant.API_PHONE_5306;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public PhoneResponse<Object> execute(PhoneRequest<JSONObject> req, AuthUser authUser)
            throws Exception {
 
        //转化为对象
        ParamDepot paramDepot = JSONObject.parseObject(req.getData().toString(), ParamDepot.class);
 
        //设置查询参数
        GasParam param = new GasParam();
        param.setCompanyId(authUser.getCompanyId());
        param.setLimit(1);
        param.setDepotId(paramDepot.getDepotId());
        List<GasData> list = coreGasService.pageQueryList(param);
 
        if(null == list || list.isEmpty()){
            return PhoneRespUtil.error(RespCodeEnum.CODE_2000,"暂无查到气体检测记录!");
        }
 
        //封装响应数据
        DtoGas dtoGas = new DtoGas();
        dtoGas.setDepotId(list.get(0).getDepotId());
        dtoGas.setReceiveDate(list.get(0).getReceiveDate());
        dtoGas.setPerCo2Max(list.get(0).getPerCo2Max());
        dtoGas.setPerCo2(list.get(0).getPerCo2());
        dtoGas.setPerCo2Min(list.get(0).getPerCo2Min());
        dtoGas.setPerO2Max(list.get(0).getPerO2Max());
        dtoGas.setPerO2(list.get(0).getPerO2());
        dtoGas.setPerO2Min(list.get(0).getPerO2Min());
        dtoGas.setPerPh3Max(list.get(0).getPerPh3Max());
        dtoGas.setPerPh3(list.get(0).getPerPh3());
        dtoGas.setPerPh3Min(list.get(0).getPerPh3Min());
        dtoGas.setPerN2Max(list.get(0).getPerN2Max());
        dtoGas.setPerN2Max(list.get(0).getPerN2Max());
        dtoGas.setPerN2Min(list.get(0).getPerN2Min());
        dtoGas.setCheckUser(list.get(0).getCheckUser());
 
        return PhoneRespUtil.success(dtoGas, req);
    }
}