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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
package com.aps.core.service.impl;
 
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.aps.common.core.utils.DateUtils;
import com.aps.common.core.utils.uuid.IdUtils;
import com.aps.common.security.utils.SecurityUtils;
import com.aps.core.domain.*;
import com.aps.core.mapper.ApsGasPipelineCapacityPlanMapper;
import com.aps.core.mapper.ApsGasPipingPlanMapper;
import com.aps.core.mapper.ApsGasPipingRouteStatMapper;
import com.aps.core.service.IApsGasMaterialUsageService;
import com.aps.core.service.IApsGasPipingRouteStatService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
 
/**
 * 气体管路产能负载统计Service业务层处理
 * 
 * @author hjy
 * @date 2025-04-24
 */
@Slf4j
@Service
public class ApsGasPipingRouteStatServiceImpl implements IApsGasPipingRouteStatService 
{
    @Autowired
    private ApsGasPipingRouteStatMapper apsGasPipingRouteStatMapper;
 
    @Autowired
    private ApsGasPipingPlanMapper apsGasPipingPlanMapper;
 
    @Autowired
    private ApsGasPipelineCapacityPlanMapper apsGasPipelineCapacityPlanMapper;
 
    @Autowired
    private IApsGasMaterialUsageService apsGasMaterialUsageService;
 
    /**
     * 查询气体管路产能负载统计
     * 
     * @param id 气体管路产能负载统计主键
     * @return 气体管路产能负载统计
     */
    @Override
    public ApsGasPipingRouteStat selectApsGasPipingRouteStatById(String id)
    {
        return apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatById(id);
    }
 
    /**
     * 查询气体管路产能负载统计列表
     * 
     * @param apsGasPipingRouteStat 气体管路产能负载统计
     * @return 气体管路产能负载统计
     */
    @Override
    public List<ApsGasPipingRouteStat> selectApsGasPipingRouteStatList(ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        return apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(apsGasPipingRouteStat);
    }
 
    /**
     * 新增气体管路产能负载统计
     * 
     * @param apsGasPipingRouteStat 气体管路产能负载统计
     * @return 结果
     */
    @Override
    public int insertApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate());
        apsGasPipingRouteStat.setCreateBy(SecurityUtils.getUsername());
        return apsGasPipingRouteStatMapper.insertApsGasPipingRouteStat(apsGasPipingRouteStat);
    }
 
    /**
     * 修改气体管路产能负载统计
     * 
     * @param apsGasPipingRouteStat 气体管路产能负载统计
     * @return 结果
     */
    @Override
    public int updateApsGasPipingRouteStat(ApsGasPipingRouteStat apsGasPipingRouteStat)
    {
        apsGasPipingRouteStat.setUpdateBy(SecurityUtils.getUsername());
        apsGasPipingRouteStat.setUpdateTime(DateUtils.getNowDate());
        return apsGasPipingRouteStatMapper.updateApsGasPipingRouteStat(apsGasPipingRouteStat);
    }
 
    /**
     * 批量删除气体管路产能负载统计
     * 
     * @param ids 需要删除的气体管路产能负载统计主键
     * @return 结果
     */
    @Override
    public int deleteApsGasPipingRouteStatByIds(String[] ids)
    {
        return apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatByIds(ids);
    }
 
    /**
     * 删除气体管路产能负载统计信息
     * 
     * @param id 气体管路产能负载统计主键
     * @return 结果
     */
    @Override
    public int deleteApsGasPipingRouteStatById(String id)
    {
        return apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatById(id);
    }
 
    @Override
    public boolean computeCapacity() {
//        PageHelper.startPage(1, 500);
        List<ApsGasPipingPlan> apsGasPipingPlans = apsGasPipingPlanMapper.selectApsGasPipingPlanWithProcess(new ApsGasPipingPlan());
        List<ApsGasPipingRouteStat> apsGasPipingRouteStatList = new ArrayList<>();
        /*本次计算批次号*/
        String batchNum = IdUtils.fastSimpleUUID();
        try {
            apsGasPipingPlans.forEach(apsGasPipingPlan -> {
                List<ApsProcessRoute> apsProcessRoutes = apsGasPipingPlan.getApsProcessRoutes();
                //按照工序序号升序排序
                apsProcessRoutes.sort((a, b)->a.getProcessNumber().compareTo(b.getProcessNumber()));
                //是否找到当前工序
                boolean isFind = false;
                for (int i=0;i<apsProcessRoutes.size();i++){
                    ApsProcessRoute apsProcessRoute = apsProcessRoutes.get(i);
                    ApsGasPipingRouteStat apsGasPipingRouteStat = new ApsGasPipingRouteStat();
                    //工单号
                    apsGasPipingRouteStat.setWorkOrderNo(apsGasPipingPlan.getDocumentNumber());
                    //料号
                    apsGasPipingRouteStat.setItemNumber(apsGasPipingPlan.getItemNumber());
                    //当前工序号
                    apsGasPipingRouteStat.setCurrentProcessNumber(apsGasPipingPlan.getProcessNumber());
                    //生产数量
                    apsGasPipingRouteStat.setProductionQuantity(apsGasPipingPlan.getProductionQuantity());
                    //工序名称
                    apsGasPipingRouteStat.setProcessName(apsProcessRoute.getProcessName());
                    //工序号
                    apsGasPipingRouteStat.setRoadProcessNumber(apsProcessRoute.getProcessNumber());
                    //标准工时
                    apsGasPipingRouteStat.setStandardTime(apsProcessRoute.getStandardTime());
                    //专业
                    apsGasPipingRouteStat.setMajor(apsGasPipingPlan.getPlanType());
                    //工序总工时 等于 标准工时*生产数量
                    apsGasPipingRouteStat.setProcessTotalTime(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity()));
                    //计划开工日
                    if(apsGasPipingRouteStat.getCurrentProcessNumber().equals(apsGasPipingRouteStat.getRoadProcessNumber())) {
                        /* 对 stat.getProcessPlanStartDay() 和当前日期 进行对比,只对比到日,不用管十分秒*/
                        LocalDate startLocalDate = LocalDate.ofInstant(apsProcessRoute.getProcessPlanStartDay().toInstant(), ZoneId.systemDefault());
                        LocalDate nowLocalDate = LocalDate.now();
                        if (startLocalDate.isBefore(nowLocalDate)) {
                            apsGasPipingRouteStat.setProcessPlanStartDay(new Date());
                        }else{
                            apsGasPipingRouteStat.setProcessPlanStartDay(apsProcessRoute.getProcessPlanStartDay());
                        }
                        isFind = true;
                    }
                    if(!isFind){
                        continue;
                    }
                    // 上一道工序的结束时间 = 上一道工序的开始时间 + 上一道工序的总工时
                    if(apsGasPipingRouteStat.getProcessPlanStartDay()==null){
                        LocalDateTime previousProcessPlanStartDay = apsProcessRoutes.get(i - 1).getProcessPlanStartDay().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
                        long previousProcessTotalTime = apsGasPipingRouteStatList.get(i - 1).getProcessTotalTime().longValue();
                        LocalDateTime currentProcessPlanStartDay = previousProcessPlanStartDay.plusHours(previousProcessTotalTime);
                        apsGasPipingRouteStat.setProcessPlanStartDay(Date.from(Timestamp.valueOf(currentProcessPlanStartDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).toInstant()));
                    }
                    //插入 年 月 日
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String formattedDate = sdf.format(apsGasPipingRouteStat.getProcessPlanStartDay());
                    String[] dateParts = formattedDate.split("-");
                    apsGasPipingRouteStat.setPlanStartYear(String.valueOf(Integer.parseInt(dateParts[0])));
                    apsGasPipingRouteStat.setPlanStartMonth(String.valueOf(Integer.parseInt(dateParts[1])));
                    apsGasPipingRouteStat.setPlanStartDay(String.valueOf(Integer.parseInt(dateParts[2])));
                    //标准用量 查询物料用量表
//                    ApsGasMaterialUsage apsGasMaterialUsage = new ApsGasMaterialUsage();
//                    apsGasMaterialUsage.setItemNumber(apsGasPipingPlan.getItemNumber());
//                    apsGasMaterialUsage.setProcessName(apsProcessRoute.getProcessName());
//                    List<ApsGasMaterialUsage> apsGasMaterialUsageList = apsGasMaterialUsageService.selectApsGasMaterialUsageList(apsGasMaterialUsage);
                    apsGasPipingRouteStat.setStandardDosage(apsProcessRoute.getStandardTime().multiply(apsGasPipingPlan.getProductionQuantity()));
                    //工序总用量 = 标准用量*生产数量
                    apsGasPipingRouteStat.setProcessTotalDosage(apsGasPipingRouteStat.getStandardDosage().multiply(apsGasPipingPlan.getProductionQuantity()));
                    apsGasPipingRouteStat.setCreateTime(DateUtils.getNowDate());
                    apsGasPipingRouteStat.setCreateBy("auto");
                    apsGasPipingRouteStat.setBatchNumber(batchNum);
                    apsGasPipingRouteStat.setId(IdUtils.fastSimpleUUID());
                    apsGasPipingRouteStatList.add(apsGasPipingRouteStat);
                }
            });
            List<ApsGasPipingRouteStat> tempInsertList = new ArrayList<>();
            for (int i = 0; i < apsGasPipingRouteStatList.size(); i++) {
                tempInsertList.add(apsGasPipingRouteStatList.get(i));
                if(tempInsertList.size()==500){
                    apsGasPipingRouteStatMapper.insertApsGasPipingRouteStatBatch(tempInsertList);
                    tempInsertList = new ArrayList<>();
                }else if(i==apsGasPipingRouteStatList.size()-1){
                    apsGasPipingRouteStatMapper.insertApsGasPipingRouteStatBatch(tempInsertList);
                }
            }
            apsGasPipingRouteStatMapper.deleteApsGasPipingRouteStatByBatchNum(batchNum);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
 
    @Override
    public JSONObject getCapacityPlanData(ApsGasPipingRouteStat apsGasPipingRouteStat) {
        JSONObject result = new JSONObject();
        HashSet<String> startPlanTimeSet = new HashSet<>();
        JSONArray processData = new JSONArray();
        try {
            //获取工序计划产能数据
            HashMap<String, ApsGasPipelineCapacityPlan> apsGasPipingPlanMap = new HashMap<>();
            List<ApsGasPipelineCapacityPlan> apsGasPipelineCapacityPlanList = apsGasPipelineCapacityPlanMapper.selectApsGasPipelineCapacityPlanList(new ApsGasPipelineCapacityPlan());
            apsGasPipelineCapacityPlanList.forEach(apsGasPipelineCapacityPlan -> {
                apsGasPipingPlanMap.put(apsGasPipelineCapacityPlan.getProcessName(),apsGasPipelineCapacityPlan);
            });
            //计算日产能数据
            DateTimeFormatter formatter = null;
            List<ApsGasPipingRouteStat> apsGasPipingRouteStats;
            SimpleDateFormat simpleDateFormat = null;
            YearMonth yearMonth = YearMonth.parse(apsGasPipingRouteStat.getSearchEndDate());
            int daysInMonth = yearMonth.lengthOfMonth();
            apsGasPipingRouteStat.setSearchStartDate(apsGasPipingRouteStat.getSearchStartDate()+"-01 00:00:00");
            apsGasPipingRouteStat.setSearchEndDate(apsGasPipingRouteStat.getSearchEndDate()+"-"+ daysInMonth +" 23:59:59");
            if("day".equals(apsGasPipingRouteStat.getSearchType())){
                formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            }else if("month".equals(apsGasPipingRouteStat.getSearchType())){
                formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                simpleDateFormat = new SimpleDateFormat("yyyy-MM");
            }
            apsGasPipingRouteStats = apsGasPipingRouteStatMapper.selectApsGasPipingRouteStatList(apsGasPipingRouteStat);
            //根据开工日进行升序排序
            apsGasPipingRouteStats.sort((a, b)->a.getProcessPlanStartDay().compareTo(b.getProcessPlanStartDay()));
            //工序分组统计
            HashMap<String, List<ApsResourceDateStat>> processMap = new HashMap<>();
            List<HashMap<String, List<ApsResourceDateStat>>> processList = new ArrayList<>();
            //工序开工日期
            String planStartDate = "";
            //统计所有工序对应的开工时间
            for (ApsGasPipingRouteStat apsGasPipingRouteStatTemp : apsGasPipingRouteStats) {
                planStartDate = simpleDateFormat.format(apsGasPipingRouteStatTemp.getProcessPlanStartDay());
                if("month".equals(apsGasPipingRouteStat.getSearchType())){
                    planStartDate = planStartDate+"-01";
                }
                ApsResourceDateStat apsResourceDateStat = new ApsResourceDateStat();
                apsResourceDateStat.setPlanDay(LocalDate.parse(planStartDate, formatter));
                apsResourceDateStat.setResourceName(apsGasPipingRouteStatTemp.getProcessName());
                //查询气柜管路产能规划表
                apsResourceDateStat.setDesignTimes(apsGasPipingPlanMap.get(apsGasPipingRouteStatTemp.getProcessName())!=null?apsGasPipingPlanMap.get(apsGasPipingRouteStatTemp.getProcessName()).getDayProduceAllNum().intValue():0);
                //查询料号工序产能表
                apsResourceDateStat.setRequireTimes(apsGasPipingRouteStatTemp.getProcessTotalTime().intValue());
                if(apsResourceDateStat.getDesignTimes()!=0){
                    apsResourceDateStat.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStat.getRequireTimes()/apsResourceDateStat.getDesignTimes()* 100L));
                }else{
                    apsResourceDateStat.setCapacityLoad(BigDecimal.valueOf(0));
                }
                List<ApsResourceDateStat> apsResourceDateStatList = new ArrayList<>();
                if(processMap.containsKey(apsGasPipingRouteStatTemp.getProcessName())){
                    apsResourceDateStatList = processMap.get(apsGasPipingRouteStatTemp.getProcessName());
                }
                apsResourceDateStatList.add(apsResourceDateStat);
                processMap.put(apsGasPipingRouteStatTemp.getProcessName(), apsResourceDateStatList);
            }
            //聚合每道工序的开工时间和产能
            processMap.forEach((processName, apsResourceDateStatList) -> {
                LinkedHashMap<String, ApsResourceDateStat> dayMap = new LinkedHashMap<>();
                apsResourceDateStatList.forEach(apsResourceDateStat -> {
                    startPlanTimeSet.add(apsResourceDateStat.getPlanDay().toString());
                    if(dayMap.containsKey(apsResourceDateStat.getPlanDay().toString())){
                        ApsResourceDateStat apsResourceDateStatTemp = dayMap.get(apsResourceDateStat.getPlanDay().toString());
                        apsResourceDateStatTemp.setDesignTimes(apsGasPipingPlanMap.get(processName)!=null?apsGasPipingPlanMap.get(processName).getMonthProduceAllNum().intValue():0);
                        apsResourceDateStatTemp.setRequireTimes(apsResourceDateStatTemp.getRequireTimes()+apsResourceDateStat.getRequireTimes());
                        if(apsResourceDateStatTemp.getDesignTimes()!=0){
                            apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(apsResourceDateStatTemp.getRequireTimes()/apsResourceDateStatTemp.getDesignTimes()* 100L));
                        }else{
                            apsResourceDateStatTemp.setCapacityLoad(BigDecimal.valueOf(0));
                        }
                        apsResourceDateStatTemp.setResourceGroupName(processName);
                        apsResourceDateStatTemp.setPlanDay(apsResourceDateStat.getPlanDay());
                        dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStatTemp);
                    }else{
                        dayMap.put(apsResourceDateStat.getPlanDay().toString(), apsResourceDateStat);
                    }
                });
                List<ApsResourceDateStat> tempList = new ArrayList<>();
                dayMap.forEach((key, value) -> {
                    tempList.add(value);
                });
//                processMap.put(processName, tempList);
                HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>();
                temp.put(processName, tempList);
                processList.add(temp);
            });
//            for (String key : processMap.keySet()) {
//                HashMap<String, List<ApsResourceDateStat>> temp = new HashMap<>();
//                temp.put(key, processMap.get(key));
//                processList.add(temp);
//            }
            //排序时间标题
            List<String> sortedStartPlanTimeList = new ArrayList<>(startPlanTimeSet);
            Collections.sort(sortedStartPlanTimeList);
            result.put("planTable", processList);
            result.put("planTitle", sortedStartPlanTimeList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
 
    @Override
    public void exportExcel(HttpServletResponse response, ApsGasPipingRouteStat apsGasPipingRouteStat) {
        SXSSFWorkbook wb = new SXSSFWorkbook(500);
        wb.createSheet();
        wb.setSheetName(0, "气柜管路产能负载统计表");
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
 
        Map<String, CellStyle> styles = createStyles(wb);
        CellStyle title = styles.get("title");
        try
        {
            JSONObject stat = getCapacityPlanData(apsGasPipingRouteStat);
            List<String> days = (List<String>) stat.get("planTitle");
            List<HashMap<String, List<ApsResourceDateStat>>> table= (List<HashMap<String, List<ApsResourceDateStat>>>) stat.get("planTable");
            SXSSFSheet sheet = wb.getSheetAt(0);
            /*填写日期列 和 工时列*/
            SXSSFRow rowDay = sheet.createRow(0);
            SXSSFRow rowTitle = sheet.createRow(1);
 
            SXSSFCell daytitle = rowDay.createCell(0);
            daytitle.setCellValue("日期");
            daytitle.setCellStyle(title);
            SXSSFCell titleCell = rowTitle.createCell(0);
            titleCell.setCellValue("工序");
            titleCell.setCellStyle(title);
 
            for (int i = 0; i < days.size(); i++) {
                SXSSFCell dateCell = rowDay.createCell(i * 3 + 1);
                SXSSFCell designHoursCell = rowTitle.createCell(i * 3 + 1);
                SXSSFCell requireHoursCell = rowTitle.createCell(i * 3 + 2);
                SXSSFCell loadCell = rowTitle.createCell(i * 3 + 3);
                dateCell.setCellValue(days.get(i));
                designHoursCell.setCellValue("设计工时");
                requireHoursCell.setCellValue("需求工时");
                loadCell.setCellValue("产能负荷");
                /*set cell style*/
                dateCell.setCellStyle(title);
                designHoursCell.setCellStyle(title);
                requireHoursCell.setCellStyle(title);
                loadCell.setCellStyle(title);
 
                /*合并日期单元格*/
                sheet.addMergedRegion( new CellRangeAddress(0, 0, i*3+1, i*3+3));
            }
            for (int i = 0; i < table.size(); i++) {
                Map<String, List<ApsResourceDateStat>> resourceList = table.get(i);
                /*创建数据行*/
                SXSSFRow dataRow  = sheet.createRow(i+2);
                for( Map.Entry<String, List<ApsResourceDateStat>> entry : resourceList.entrySet()){
                    String resourceName = entry.getKey();
                    List<ApsResourceDateStat> resourceDateStats = entry.getValue();
                    dataRow.createCell(0).setCellValue(resourceName);
                    for (int j = 0; j < resourceDateStats.size(); j++) {
                        ApsResourceDateStat apsResourceDateStat = resourceDateStats.get(j);
                        dataRow.createCell(j*3+1).setCellValue(apsResourceDateStat.getDesignTimes());
                        dataRow.createCell(j*3+2).setCellValue(apsResourceDateStat.getRequireTimes());
                        if(apsResourceDateStat.getCapacityLoad()!=null){
                            dataRow.createCell(j*3+3).setCellValue(apsResourceDateStat.getCapacityLoad().doubleValue()+"%");
                        }else{
                            dataRow.createCell(j*3+3).setCellValue("%");
                        }
                    }
                }
 
            }
            wb.write(response.getOutputStream());
        }
        catch (Exception e)
        {
            log.error("导出Excel异常{}", e.getMessage());
        }
        finally
        {
            IOUtils.closeQuietly(wb);
        }
    }
    private Map<String,CellStyle> createStyles(SXSSFWorkbook wb)
    {
        Map<String,CellStyle> styles=new HashMap<>();
        CellStyle style = wb.createCellStyle();
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        Font titleFont = wb.createFont();
        titleFont.setFontName("Arial");
        titleFont.setFontHeightInPoints((short) 12);
        titleFont.setBold(true);
        style.setFont(titleFont);
        DataFormat dataFormat = wb.createDataFormat();
        style.setDataFormat(dataFormat.getFormat("@"));
        styles.put("title", style);
        return styles;
    }
}