CZT
2023-09-06 71c4fa1e27f75ae4b765c95c67a3069c84dc72ba
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
package com.ld.igds.sh.service;
 
import com.bstek.bdf2.core.model.DefaultDept;
import com.ld.igds.log.service.InteStatusLogService;
import com.ld.igds.models.InteStatusLog;
import com.ld.igds.sh.dto.ApiResponse;
import com.ld.igds.sh.dto.Dto1102;
import com.ld.igds.sh.param.ApiRequest;
import com.ld.igds.sh.service.impl.HApiShServiceImpl;
import com.ld.igds.sh.util.ApiShConst;
import com.ld.igds.sh.util.RespCodeEnum;
import com.ld.igds.sh.util.RespUtil;
import com.ld.igds.util.ContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * 库区信息数据接口
 *
 * @author chen
 */
@Slf4j
@Service
public class ApiShServiceImpl1102 implements ApiShService {
 
    @Autowired
    private HApiShServiceImpl hApiShServiceImpl;
    @Autowired
    private InteStatusLogService inteStatusLogService;
    @Override
    public String getInterfaceId() {
        return ApiShConst.API_SH_1102;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public ApiResponse<Object> execute(ApiRequest<Object> request){
        //获取参数信息
        String deptId = request.getDeptId();
 
        //获取单位信息
        String companyId = ContextUtil.getDefaultCompanyId();
        List<DefaultDept> deptList = hApiShServiceImpl.listDept(companyId, companyId);
 
        //响应数据为空则直接返回响应码2000
        if (deptList == null || deptList.isEmpty()) {
            return RespUtil.error(RespCodeEnum.CODE_2000.getCode(), request);
        }
 
        //封装数据
        List<Dto1102> list = new ArrayList<>();
        Dto1102 dto;
        InteStatusLog log;
        InteStatusLog addLog;
        for (DefaultDept dept : deptList) {
            dto = new Dto1102();
            dto.setKqbm(dept.getCode());
            dto.setSsdwdm(dept.getCode().substring(0,18));
            dto.setKqmc(dept.getName());
            dto.setKqdz(dept.getAddress());
            dto.setXzqhbm(dept.getCountry());
            dto.setKqcq(dept.getPropertyRight());
            dto.setYxcr(dept.getStorage()==null?"0.0":dept.getStorage() + "");
            dto.setYxgr(dept.getOilStorage()==null?"0.0":dept.getOilStorage() + "");
            dto.setZdmj(dept.getArea()==null?"0.0":dept.getArea() + "");
            dto.setCfs(dept.getBuildingNum() == null ? "0" : dept.getBuildingNum() + "");
            dto.setYgs(dept.getOilNum() == null ? "0" : dept.getOilNum() + "");
            dto.setJd(dept.getLon() == null ? "" : dept.getLon() + "");
            dto.setWd(dept.getLat() == null ? "" : dept.getLat() + "");
            dto.setSfdc(dept.getActingReserve());
 
            dto.setXzqhnm(dept.getCountry());
            dto.setXzqhmc(dept.getCountry());
            dto.setYgrl(dept.getOilStorage()==null?"0.0":dept.getOilStorage() + "");
            dto.setYggs(dept.getOilNum() == null ? "0" : dept.getOilNum() + "");
            dto.setZskbm(dept.getCode());
 
            dto.setZhgxsj(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
            //查询日志状态表,设置操作标志
            log = inteStatusLogService.getLogByBizId(companyId, ApiShConst.API_SH_1102 + "_" + dept.getId());
            if(null == log){
                addLog = new InteStatusLog();
                addLog.setBizId(ApiShConst.API_SH_1102 + "_" + dept.getId());
                addLog.setCompanyId(companyId);
                addLog.setBizType(ApiShConst.API_SH_TYPE_BASIC);
                addLog.setInterfaceId(ApiShConst.API_SH_1102);
                addLog.setInterfaceType(ApiShConst.API_SH_TYPE_BASIC);
                addLog.setStatus(ApiShConst.API_SH_STATUS_SUCCESS);
 
                inteStatusLogService.addInteStatusLog(addLog);
            }else {
                dto.setCzbz(ApiShConst.API_SH_U);
            }
 
            list.add(dto);
        }
 
        //响应数据为空则直接返回响应码2000
        if (list.isEmpty()) {
            return RespUtil.error(RespCodeEnum.CODE_2000.getCode(), request);
        }
 
        return RespUtil.success(list, request);
    }
}