liulingling.177216
2024-08-26 349f1cfc5fa77fbc636d542df0d8050fddec48c2
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
package com.dingzhuo.energy.project.statisticalData.service.impl;
 
import java.util.ArrayList;
import java.util.List;
 
import com.dingzhuo.energy.project.statisticalData.domain.GxdhCountIndex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dingzhuo.energy.project.statisticalData.mapper.GxdhCountMapper;
import com.dingzhuo.energy.project.statisticalData.domain.GxdhCount;
import com.dingzhuo.energy.project.statisticalData.service.IGxdhCountService;
 
/**
 * 工序单耗统计功能Service业务层处理
 * 
 * @author zhaow
 * @date 2020-12-26
 */
@Service
public class GxdhCountServiceImpl implements IGxdhCountService 
{
    @Autowired
    private GxdhCountMapper gxdhCountMapper;
 
    /**
     * 查询工序单耗统计功能
     * 
     * @param id 工序单耗统计功能ID
     * @return 工序单耗统计功能
     */
    @Override
    public GxdhCount selectGxdhCountById(String id)
    {
        return gxdhCountMapper.selectGxdhCountById(id);
    }
 
    /**
     * 查询工序单耗统计功能列表
     * 
     * @param gxdhCount 工序单耗统计功能
     * @return 工序单耗统计功能
     */
    @Override
    public List<GxdhCount> selectGxdhCountList(GxdhCount gxdhCount)
    {
        return gxdhCountMapper.selectGxdhCountList(gxdhCount);
    }
 
    /**
     * 新增工序单耗统计功能
     * 
     * @param gxdhCount 工序单耗统计功能
     * @return 结果
     */
    @Override
    public int insertGxdhCount(GxdhCount gxdhCount)
    {
        return gxdhCountMapper.insertGxdhCount(gxdhCount);
    }
 
    /**
     * 修改工序单耗统计功能
     * 
     * @param gxdhCount 工序单耗统计功能
     * @return 结果
     */
    @Override
    public int updateGxdhCount(GxdhCount gxdhCount)
    {
        return gxdhCountMapper.updateGxdhCount(gxdhCount);
    }
 
    /**
     * 批量删除工序单耗统计功能
     * 
     * @param ids 需要删除的工序单耗统计功能ID
     * @return 结果
     */
    @Override
    public int deleteGxdhCountByIds(String[] ids)
    {
        return gxdhCountMapper.deleteGxdhCountByIds(ids);
    }
 
    /**
     * 删除工序单耗统计功能信息
     * 
     * @param id 工序单耗统计功能ID
     * @return 结果
     */
    @Override
    public int deleteGxdhCountById(String id)
    {
        return gxdhCountMapper.deleteGxdhCountById(id);
    }
 
    /**
     * 查询工序单耗统计功能报表的指标数据列表
     *
     * @param gxdhCountIndex 工序单耗统计功能报表的指标数据
     * @return 工序单耗统计功能集合
     */
    public List<GxdhCountIndex> selectGxdhCountIndexList(GxdhCountIndex gxdhCountIndex){
        List<GxdhCountIndex> resList = new ArrayList<>();
        GxdhCountIndex nyxhl = new GxdhCountIndex();
        nyxhl.setVarietyType("能源消耗量");
 
        GxdhCountIndex cpcl = new GxdhCountIndex();
        cpcl.setVarietyType("产品产量");
 
        GxdhCountIndex cpdh = new GxdhCountIndex();
        cpdh.setVarietyType("产品单耗");
        //先查 能源消耗量
        gxdhCountIndex.setVarietyType("NYXHL");
        List<GxdhCountIndex> queryNyxhlRes = gxdhCountMapper.selectGxdhCountIndexList(gxdhCountIndex);
        if(queryNyxhlRes!=null && queryNyxhlRes.size()>0)
        {
            for(GxdhCountIndex gxdhCountIndexT:queryNyxhlRes)
            {
                if(gxdhCountIndexT.getFL().equals("DIAN"))
                {
                    nyxhl.setA1(gxdhCountIndexT.getA1());
                    nyxhl.setA4(gxdhCountIndexT.getA2());
                    nyxhl.setA7(gxdhCountIndexT.getA3());
                    nyxhl.setA10(gxdhCountIndexT.getA4());
                    nyxhl.setA13(gxdhCountIndexT.getA5());
                    nyxhl.setA16(gxdhCountIndexT.getA6());
                    nyxhl.setA19(gxdhCountIndexT.getA7());
                    nyxhl.setA22(gxdhCountIndexT.getA8());
                    nyxhl.setA25(gxdhCountIndexT.getA9());
                    nyxhl.setA28(gxdhCountIndexT.getA10());
                    nyxhl.setA31(gxdhCountIndexT.getA11());
                    nyxhl.setA34(gxdhCountIndexT.getA12());
                }else if(gxdhCountIndexT.getFL().equals("MQ"))
                {
                    nyxhl.setA2(gxdhCountIndexT.getA1());
                    nyxhl.setA5(gxdhCountIndexT.getA2());
                    nyxhl.setA8(gxdhCountIndexT.getA3());
                    nyxhl.setA11(gxdhCountIndexT.getA4());
                    nyxhl.setA14(gxdhCountIndexT.getA5());
                    nyxhl.setA17(gxdhCountIndexT.getA6());
                    nyxhl.setA20(gxdhCountIndexT.getA7());
                    nyxhl.setA23(gxdhCountIndexT.getA8());
                    nyxhl.setA26(gxdhCountIndexT.getA9());
                    nyxhl.setA29(gxdhCountIndexT.getA10());
                    nyxhl.setA32(gxdhCountIndexT.getA11());
                    nyxhl.setA35(gxdhCountIndexT.getA12());
                }else if(gxdhCountIndexT.getFL().equals("ZQ"))
                {
                    nyxhl.setA3(gxdhCountIndexT.getA1());
                    nyxhl.setA6(gxdhCountIndexT.getA2());
                    nyxhl.setA9(gxdhCountIndexT.getA3());
                    nyxhl.setA12(gxdhCountIndexT.getA4());
                    nyxhl.setA15(gxdhCountIndexT.getA5());
                    nyxhl.setA18(gxdhCountIndexT.getA6());
                    nyxhl.setA21(gxdhCountIndexT.getA7());
                    nyxhl.setA24(gxdhCountIndexT.getA8());
                    nyxhl.setA27(gxdhCountIndexT.getA9());
                    nyxhl.setA30(gxdhCountIndexT.getA10());
                    nyxhl.setA33(gxdhCountIndexT.getA11());
                    nyxhl.setA36(gxdhCountIndexT.getA12());
                }
            }
        }
 
        //再查  产品产量
        gxdhCountIndex.setVarietyType("CPCL");
        List<GxdhCountIndex> queryCpclRes = gxdhCountMapper.selectGxdhCountIndexList(gxdhCountIndex);
        if(queryCpclRes!=null && queryCpclRes.size()>0)
        {
            for(GxdhCountIndex gxdhCountIndexCpcl:queryCpclRes)
            {
                if(gxdhCountIndexCpcl.getFL().equals("DIAN"))
                {
                    cpcl.setA1(gxdhCountIndexCpcl.getA1());
                    cpcl.setA4(gxdhCountIndexCpcl.getA2());
                    cpcl.setA7(gxdhCountIndexCpcl.getA3());
                    cpcl.setA10(gxdhCountIndexCpcl.getA4());
                    cpcl.setA13(gxdhCountIndexCpcl.getA5());
                    cpcl.setA16(gxdhCountIndexCpcl.getA6());
                    cpcl.setA19(gxdhCountIndexCpcl.getA7());
                    cpcl.setA22(gxdhCountIndexCpcl.getA8());
                    cpcl.setA25(gxdhCountIndexCpcl.getA9());
                    cpcl.setA28(gxdhCountIndexCpcl.getA10());
                    cpcl.setA31(gxdhCountIndexCpcl.getA11());
                    cpcl.setA34(gxdhCountIndexCpcl.getA12());
                }else if(gxdhCountIndexCpcl.getFL().equals("MQ"))
                {
                    cpcl.setA2(gxdhCountIndexCpcl.getA1());
                    cpcl.setA5(gxdhCountIndexCpcl.getA2());
                    cpcl.setA8(gxdhCountIndexCpcl.getA3());
                    cpcl.setA11(gxdhCountIndexCpcl.getA4());
                    cpcl.setA14(gxdhCountIndexCpcl.getA5());
                    cpcl.setA17(gxdhCountIndexCpcl.getA6());
                    cpcl.setA20(gxdhCountIndexCpcl.getA7());
                    cpcl.setA23(gxdhCountIndexCpcl.getA8());
                    cpcl.setA26(gxdhCountIndexCpcl.getA9());
                    cpcl.setA29(gxdhCountIndexCpcl.getA10());
                    cpcl.setA32(gxdhCountIndexCpcl.getA11());
                    cpcl.setA35(gxdhCountIndexCpcl.getA12());
                }else if(gxdhCountIndexCpcl.getFL().equals("ZQ"))
                {
                    cpcl.setA3(gxdhCountIndexCpcl.getA1());
                    cpcl.setA6(gxdhCountIndexCpcl.getA2());
                    cpcl.setA9(gxdhCountIndexCpcl.getA3());
                    cpcl.setA12(gxdhCountIndexCpcl.getA4());
                    cpcl.setA15(gxdhCountIndexCpcl.getA5());
                    cpcl.setA18(gxdhCountIndexCpcl.getA6());
                    cpcl.setA21(gxdhCountIndexCpcl.getA7());
                    cpcl.setA24(gxdhCountIndexCpcl.getA8());
                    cpcl.setA27(gxdhCountIndexCpcl.getA9());
                    cpcl.setA30(gxdhCountIndexCpcl.getA10());
                    cpcl.setA33(gxdhCountIndexCpcl.getA11());
                    cpcl.setA36(gxdhCountIndexCpcl.getA12());
                }
            }
        }
 
        resList.add(nyxhl);
        resList.add(cpcl);
        //计算产品单耗=能源消耗量/产品产量
        cpdh.setA1(calculationCpdh(nyxhl.getA1(),cpcl.getA1()));
        cpdh.setA2(calculationCpdh(nyxhl.getA2(),cpcl.getA2()));
        cpdh.setA3(calculationCpdh(nyxhl.getA3(),cpcl.getA3()));
        cpdh.setA4(calculationCpdh(nyxhl.getA4(),cpcl.getA4()));
        cpdh.setA5(calculationCpdh(nyxhl.getA5(),cpcl.getA5()));
        cpdh.setA6(calculationCpdh(nyxhl.getA6(),cpcl.getA6()));
        cpdh.setA7(calculationCpdh(nyxhl.getA7(),cpcl.getA7()));
        cpdh.setA8(calculationCpdh(nyxhl.getA8(),cpcl.getA8()));
        cpdh.setA9(calculationCpdh(nyxhl.getA9(),cpcl.getA9()));
        cpdh.setA10(calculationCpdh(nyxhl.getA10(),cpcl.getA10()));
        cpdh.setA11(calculationCpdh(nyxhl.getA11(),cpcl.getA11()));
        cpdh.setA12(calculationCpdh(nyxhl.getA12(),cpcl.getA12()));
        cpdh.setA13(calculationCpdh(nyxhl.getA13(),cpcl.getA13()));
        cpdh.setA14(calculationCpdh(nyxhl.getA14(),cpcl.getA14()));
        cpdh.setA15(calculationCpdh(nyxhl.getA15(),cpcl.getA15()));
        cpdh.setA16(calculationCpdh(nyxhl.getA16(),cpcl.getA16()));
        cpdh.setA17(calculationCpdh(nyxhl.getA17(),cpcl.getA17()));
        cpdh.setA18(calculationCpdh(nyxhl.getA18(),cpcl.getA18()));
        cpdh.setA19(calculationCpdh(nyxhl.getA19(),cpcl.getA19()));
        cpdh.setA20(calculationCpdh(nyxhl.getA20(),cpcl.getA20()));
        cpdh.setA21(calculationCpdh(nyxhl.getA21(),cpcl.getA21()));
        cpdh.setA22(calculationCpdh(nyxhl.getA22(),cpcl.getA22()));
        cpdh.setA23(calculationCpdh(nyxhl.getA23(),cpcl.getA23()));
        cpdh.setA24(calculationCpdh(nyxhl.getA24(),cpcl.getA24()));
        cpdh.setA25(calculationCpdh(nyxhl.getA25(),cpcl.getA25()));
        cpdh.setA26(calculationCpdh(nyxhl.getA26(),cpcl.getA26()));
        cpdh.setA27(calculationCpdh(nyxhl.getA27(),cpcl.getA27()));
        cpdh.setA28(calculationCpdh(nyxhl.getA28(),cpcl.getA28()));
        cpdh.setA29(calculationCpdh(nyxhl.getA29(),cpcl.getA29()));
        cpdh.setA30(calculationCpdh(nyxhl.getA30(),cpcl.getA30()));
        cpdh.setA31(calculationCpdh(nyxhl.getA31(),cpcl.getA31()));
        cpdh.setA32(calculationCpdh(nyxhl.getA32(),cpcl.getA32()));
        cpdh.setA33(calculationCpdh(nyxhl.getA33(),cpcl.getA33()));
        cpdh.setA34(calculationCpdh(nyxhl.getA34(),cpcl.getA34()));
        cpdh.setA35(calculationCpdh(nyxhl.getA35(),cpcl.getA35()));
        cpdh.setA36(calculationCpdh(nyxhl.getA36(),cpcl.getA36()));
        resList.add(cpdh);
        return resList;
    }
 
    private String calculationCpdh(String nyxhl,String cpcl)
    {
        try{
            if(nyxhl.equals("--")||cpcl.equals("--"))
            {
                return "--";
            }else{
                double fz = Double.parseDouble(nyxhl);
                double fm = Double.parseDouble(cpcl);
                return String.format("%.2f", fz/fm);
            }
        }catch (Exception e)
        {
            e.printStackTrace();
            return "--";
        }
    }
}