package com.engine.kq.biz;

import com.alibaba.fastjson.JSON;
import com.engine.kq.entity.KQUsageHistoryEntity;
import com.engine.kq.log.KQLog;
import java.io.PrintWriter;
import java.io.StringWriter;
import weaver.conn.RecordSet;
import weaver.general.ThreadVarLanguage;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: Administrator
 * @Date: 2019-03-12 22:36
 * @Description:
 */
public class KQUsageHistoryBiz {

    /**
     * 保存员工假期余额的变更记录
     *
     * @param usageHistoryEntityList
     * @return
     */
    public boolean save(List<KQUsageHistoryEntity> usageHistoryEntityList) {
        boolean flag = false;//记录操作是否执行成功
        try {
            List valueList = new ArrayList();//每一个记录使用记录SQL操作的参数集合
            List paramList = new ArrayList();//所有记录使用记录SQL操作的参数集合

            for (KQUsageHistoryEntity usageHistoryEntity : usageHistoryEntityList) {
                valueList = new ArrayList();//每一个记录使用记录SQL操作的参数集合

                Class usageHistoryEntityClass = usageHistoryEntity.getClass();
                Field[] fieldArr = usageHistoryEntityClass.getDeclaredFields();
                for (int i = 0; i < fieldArr.length; i++) {
                    Field field = fieldArr[i];
                    field.setAccessible(true);
                    valueList.add(field.get(usageHistoryEntity));
                }

                paramList.add(valueList);
            }

            String sql = "insert into kq_UsageHistory(leaveRulesId,relatedId,wfRequestId,operator,operateDate,operateTime,operateType," +
                    "belongYear,oldBaseAmount,newBaseAmount,oldExtraAmount,newExtraAmount,oldUsedAmount,newUsedAmount,oldBaseAmount2,newBaseAmount2,oldExtraAmount2,newExtraAmount2,oldUsedAmount2,newUsedAmount2," +
                    "oldMinimumUnit,newMinimumUnit,insertOrUpdate,balanceOfLeaveId,workflowid) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
            RecordSet recordSet = new RecordSet();
            flag = recordSet.executeBatchSql(sql, paramList);
            new KQLog().info("KQUsageHistoryBiz:save:"+"::paramList::"+ JSON.toJSONString(paramList));
        } catch (Exception e) {
          StringWriter errorsWriter = new StringWriter();
          e.printStackTrace(new PrintWriter(errorsWriter));
          new KQLog().info(errorsWriter.toString());
            e.printStackTrace();
        }
        return flag;
    }

    /**
     * 将员工假期余额的变更记录转换成文字表达
     *
     * @param id kq_UsageHistory表的主键ID
     * @return
     */
    public static String getDescription(String id, User user) {
        String description = "";
        try {
            /*系统语言*/
            String languageIdStr = "" + user.getLanguage();
            int languageId =user.getLanguage();
            ResourceComInfo resourceComInfo = new ResourceComInfo();
            KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo();
            KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo();
            String sql = "select * from Kq_UsageHistory where id=?";
            RecordSet recordSet = new RecordSet();
            recordSet.executeQuery(sql, id);
            if (recordSet.next()) {
                /*假期类型的ID*/
                String leaveRulesId = recordSet.getString("leaveRulesId");
                /*假期类型的名称*/
                String leaveName = Util.formatMultiLang(rulesComInfo.getLeaveName(leaveRulesId), languageIdStr);
                /*假期余额被修改的人员ID*/
                String relatedId = recordSet.getString("relatedId");
                //分部ID
                String subCompanyId = resourceComInfo.getSubCompanyID(relatedId);
                //保留几位小数
                int decimalDigit = Util.getIntValue(detailComInfo.getDecimalDigit(leaveRulesId, subCompanyId), 2);
                /*流程的requestId*/
                String wfRequestId = recordSet.getString("wfRequestId");
                /*操作者：-1--系统*/
                String operator = recordSet.getString("operator");
                /*操作者名称*/
                String operatorName = operator.equals("-1") ? SystemEnv.getHtmlLabelName(468,languageId) : Util.formatMultiLang(resourceComInfo.getLastnames(operator), languageIdStr);
                /*操作日期*/
                String operateDate = recordSet.getString("operateDate");
                /*操作时间*/
                String operateTime = recordSet.getString("operateTime");
                /*操作类型：0--单位变更、1--请假流程、2--销假流程、3--加班流程生成调休、4--打卡数据生成调休、5--管理员修改员工假期余额、6--批处理(管理员手动批处理或者系统凌晨自动批处理)、7--管理员Excel导入*/
                String operateType = recordSet.getString("operateType");
                /*员工假期余额的所属年份*/
                String belongYear = recordSet.getString("belongYear");
                /*操作之前的员工假期余额基数*/
                BigDecimal _oldBaseAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldBaseAmount"), 0));
                String oldBaseAmount = _oldBaseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之后的员工假期余额基数*/
                BigDecimal _newBaseAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("newBaseAmount"), 0));
                String newBaseAmount = _newBaseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之前的员工额外假期余额*/
                BigDecimal _oldExtraAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldExtraAmount"), 0));
                String oldExtraAmount = _oldExtraAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之后的员工额外假期余额*/
                BigDecimal _newExtraAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("newExtraAmount"), 0));
                String newExtraAmount = _newExtraAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之前的员工已休假期余额*/
                BigDecimal _oldUsedAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldUsedAmount"), 0));
                String oldUsedAmount = _oldUsedAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之后的员工已休假期余额*/
                BigDecimal _newUsedAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("newUsedAmount"), 0));
                String newUsedAmount = _newUsedAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之前的员工福利年假基数*/
                BigDecimal _oldBaseAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldBaseAmount2"), 0));
                String oldBaseAmount2 = _oldBaseAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之后的员工福利年假基数*/
                BigDecimal _newBaseAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("newBaseAmount2"), 0));
                String newBaseAmount2 = _newBaseAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之前的员工额外福利年假*/
                BigDecimal _oldExtraAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldExtraAmount2"), 0));
                String oldExtraAmount2 = _oldExtraAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之后的员工额外福利年假*/
                BigDecimal _newExtraAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("newExtraAmount2"), 0));
                String newExtraAmount2 = _newExtraAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之前的员工已休福利年假*/
                BigDecimal _oldUsedAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldUsedAmount2"), 0));
                String oldUsedAmount2 = _oldUsedAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之后的员工已休福利年假*/
                BigDecimal _newUsedAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("newUsedAmount2"), 0));
                String newUsedAmount2 = _newUsedAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                /*操作之前的员工假期余额单位：1-按天(单位：天)、2-按半天(单位：天)、3-按小时(单位：小时)、4-按整天(单位：天)*/
                String oldMinimumUnit = recordSet.getString("oldMinimumUnit");
                /*操作之后的员工假期余额单位：*/
                String newMinimumUnit = recordSet.getString("newMinimumUnit");
                /*是新增的员工假期余额还是更新员工假期余额*/
                String insertOrUpdate = recordSet.getString("insertOrUpdate");
                /*员工假期余额变更之前单位是天还是小时*/
                String oldUnitName = "";//单位名称，天/小时
                if (oldMinimumUnit.equals("1") || oldMinimumUnit.equals("2") || oldMinimumUnit.equals("4")) {
                    oldUnitName = SystemEnv.getHtmlLabelName(389325, languageId);//(天)
                } else {
                    oldUnitName = SystemEnv.getHtmlLabelName(389326, languageId);//(小时)
                }
                /*员工假期余额变更之后单位是天还是小时*/
                String newUnitName = "";//单位名称，天/小时
                if (newMinimumUnit.equals("1") || newMinimumUnit.equals("2") || newMinimumUnit.equals("4")) {
                    newUnitName = SystemEnv.getHtmlLabelName(389325, languageId);//(天)
                } else {
                    newUnitName = SystemEnv.getHtmlLabelName(389326, languageId);//(小时)
                }
                /*是否是混合模式(福利年假+法定年假)*/
                boolean isMixMode = KQLeaveRulesBiz.isMixMode(leaveRulesId);
                /*是否是调休*/
                boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(leaveRulesId);
                //操作之前的[调休]的总数
                BigDecimal _oldTotalAmount = _oldBaseAmount.add(_oldExtraAmount);
                String oldTotalAmount = _oldTotalAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                //操作之后的[调休]的总数
                BigDecimal _newTotalAmount = _newBaseAmount.add(_newExtraAmount);
                String newTotalAmount = _newTotalAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                //使用记录描述：
                description = "{operatorName}{operateDesc}，"+ SystemEnv.getHtmlLabelName(10005310, languageId)+"{belongYear}"+ SystemEnv.getHtmlLabelName(10005311, languageId)+"{leaveName}"+ SystemEnv.getHtmlLabelName(10005312, languageId)+"";
                String operateDesc = "";
                //进行了什么操作
                switch (operateType) {
                    case "0":
                        operateDesc = ""+ SystemEnv.getHtmlLabelName(10005313,languageId)+"";
                        break;
                    case "1":
                        operateDesc = ""+ SystemEnv.getHtmlLabelName(10005314,languageId)+"";
                        break;
                    case "2":
                        operateDesc = ""+ SystemEnv.getHtmlLabelName(10005315,languageId)+"";
                        break;
                    case "3":
                        operateDesc = ""+ SystemEnv.getHtmlLabelName(10005316,languageId)+"";
                        break;
                    case "4":
                        operateDesc = ""+ SystemEnv.getHtmlLabelName(10005317,languageId)+"";
                        break;
                    case "5":
                        operateDesc = ""+ SystemEnv.getHtmlLabelName(10005318,languageId)+"";
                        break;
                    case "6":
                        operateDesc = ""+ SystemEnv.getHtmlLabelName(10005319,languageId)+"";
                        break;
                    case "7":
                        operateDesc = ""+ SystemEnv.getHtmlLabelName(15376,languageId)+"Excel"+ SystemEnv.getHtmlLabelName(10005320,languageId)+"";
                        break;
                    case "8":
                        operateDesc = ""+ SystemEnv.getHtmlLabelName(10005321,languageId)+"";
                        break;
                }
                description = description.replace("{operatorName}", operatorName).replace("{operateDesc}", operateDesc)
                        .replace("{belongYear}", belongYear).replace("{leaveName}", leaveName);
                if ("PaidLeaveEnable".equalsIgnoreCase(insertOrUpdate)) {
                  String paidLeaveEnableDesc = "{operatorName}{operateDesc}, "+SystemEnv.getHtmlLabelName(	525184, languageId)+"。";
                    description = paidLeaveEnableDesc.replace("{operatorName}", operatorName).replace("{operateDesc}", operateDesc);
                } else if ("OnlyRecordLog".equalsIgnoreCase(insertOrUpdate)) {
                  String onlyRecordLogDesc = "{operatorName}{operateDesc}, "+SystemEnv.getHtmlLabelName(	525185, languageId)+"。";
                    description = onlyRecordLogDesc.replace("{operatorName}", operatorName).replace("{operateDesc}", operateDesc);
                } else if (insertOrUpdate.equalsIgnoreCase("insert")) {
                    String detailDesc = ""+ SystemEnv.getHtmlLabelName(501707,languageId)+"{item}"+ SystemEnv.getHtmlLabelName(10005322,languageId)+"{newAmount}{newUntName}";
                    if (isMixMode) {
                        description = description +
                                detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	500228, languageId)).replace("{newAmount}", newBaseAmount).replace("{newUntName}", newUnitName) + "，" +
                                detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	389745, languageId)).replace("{newAmount}", newExtraAmount).replace("{newUntName}", newUnitName) + "，" +
                                detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	389743, languageId)).replace("{newAmount}", newUsedAmount).replace("{newUntName}", newUnitName) + "，" +
                                detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	500229, languageId)).replace("{newAmount}", newBaseAmount2).replace("{newUntName}", newUnitName) + "，" +
                                detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	389746, languageId)).replace("{newAmount}", newExtraAmount2).replace("{newUntName}", newUnitName) + "，" +
                                detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	389744, languageId)).replace("{newAmount}", newUsedAmount2).replace("{newUntName}", newUnitName);
                    } else if (isTiaoXiu) {
                        if ("7".equals(operateType)) {
                            description = description +
                                    detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	355, languageId)).replace("{newAmount}", newTotalAmount).replace("{newUntName}", newUnitName) + "，" +
                                    detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	26642, languageId)).replace("{newAmount}", newUsedAmount).replace("{newUntName}", newUnitName);
                        } else {
                            detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005323,languageId)+"{newAmount}{newUntName}";
                            description = description +
                                    detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	355, languageId)).replace("{newAmount}", newTotalAmount).replace("{newUntName}", newUnitName);
                        }
                    } else {
                        description = description +
                                detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	17638, languageId)).replace("{newAmount}", newBaseAmount).replace("{newUntName}", newUnitName) + "，" +
                                detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	130286, languageId)).replace("{newAmount}", newExtraAmount).replace("{newUntName}", newUnitName) + "，" +
                                detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	26642, languageId)).replace("{newAmount}", newUsedAmount).replace("{newUntName}", newUnitName);
                    }
                } else if (insertOrUpdate.equalsIgnoreCase("update")) {
                    String detailDesc = ""+ SystemEnv.getHtmlLabelName(501707,languageId)+"{item}"+ SystemEnv.getHtmlLabelName(623,languageId)+"{oldAmount}{oldUnitName}"+ SystemEnv.getHtmlLabelName(10005324,languageId)+"{newAmount}{newUnitName}。";
                    switch (operateType) {
                        case "1":
                            detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005325,languageId)+"{diffAmount}{oldUnitName}。";
                            if (isMixMode) {
                                if (_newUsedAmount.compareTo(_oldBaseAmount) > 0) {
                                    String diffAmount = _newUsedAmount.subtract(_oldUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	525193, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName);
                                }
                                if (_newUsedAmount2.compareTo(_oldBaseAmount2) > 0) {
                                    String diffAmount = _newUsedAmount2.subtract(_oldUsedAmount2).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	525194, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName);
                                }
                            } else {
                                if (_newUsedAmount.compareTo(_oldBaseAmount) > 0) {
                                    String diffAmount = _newUsedAmount.subtract(_oldUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	1811, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName);
                                }
                            }
                            break;
                        case "2":
                            detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005323,languageId)+"{diffAmount}{oldUnitName}。";
                            if (isMixMode) {
                                if (_newUsedAmount.compareTo(_oldUsedAmount) < 0) {
                                    String diffAmount = _oldUsedAmount.subtract(_newUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	525193, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName);
                                }
                                if (_newUsedAmount2.compareTo(_oldUsedAmount2) < 0) {
                                    String diffAmount = _oldUsedAmount2.subtract(_newUsedAmount2).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	525194, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName);
                                }
                            } else {
                                if (_newUsedAmount.compareTo(_oldUsedAmount) < 0) {
                                    String diffAmount = _oldUsedAmount.subtract(_newUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	1811, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName);
                                }
                            }
                            break;
                        case "3":
                        case "4":
                            detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005323,languageId)+"{diffAmount}{oldUnitName}。";
                            if (_oldTotalAmount.compareTo(_newTotalAmount) != 0) {
                                String diffAmount = _newTotalAmount.subtract(_oldTotalAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString();
                                description = description +
                                        detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	1811, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName);
                            }
                            break;
                        case "0":
                        case "5":
                        case "6":
                        case "7":
                            if (isMixMode) {
                                if (_oldBaseAmount.compareTo(_newBaseAmount) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	500228, languageId)).replace("{oldAmount}", oldBaseAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newBaseAmount).replace("{newUnitName}", newUnitName);
                                }
                                if (_oldExtraAmount.compareTo(_newExtraAmount) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	389745, languageId)).replace("{oldAmount}", oldExtraAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newExtraAmount).replace("{newUnitName}", newUnitName);
                                }
                                if (_oldUsedAmount.compareTo(_newUsedAmount) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	389743, languageId)).replace("{oldAmount}", oldUsedAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount).replace("{newUnitName}", newUnitName);
                                }
                                if (_oldBaseAmount2.compareTo(_newBaseAmount2) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	500229, languageId)).replace("{oldAmount}", oldBaseAmount2).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newBaseAmount2).replace("{newUnitName}", newUnitName);
                                }
                                if (_oldExtraAmount2.compareTo(_newExtraAmount2) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	389746, languageId)).replace("{oldAmount}", oldExtraAmount2).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newExtraAmount2).replace("{newUnitName}", newUnitName);
                                }
                                if (_oldUsedAmount2.compareTo(_newUsedAmount2) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	389744, languageId)).replace("{oldAmount}", oldUsedAmount2).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount2).replace("{newUnitName}", newUnitName);
                                }
                            } else if (isTiaoXiu) {
                                if (_oldTotalAmount.compareTo(_newTotalAmount) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	355, languageId)).replace("{oldAmount}", oldTotalAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newTotalAmount).replace("{newUnitName}", newUnitName);
                                }
                                if (_oldUsedAmount.compareTo(_newUsedAmount) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	26642, languageId)).replace("{oldAmount}", oldUsedAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount).replace("{newUnitName}", newUnitName);
                                }
                            } else {
                                if (_oldBaseAmount.compareTo(_newBaseAmount) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	17638, languageId)).replace("{oldAmount}", oldBaseAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newBaseAmount).replace("{newUnitName}", newUnitName);
                                }
                                if (_oldExtraAmount.compareTo(_newExtraAmount) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	130286, languageId)).replace("{oldAmount}", oldExtraAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newExtraAmount).replace("{newUnitName}", newUnitName);
                                }
                                if (_oldUsedAmount.compareTo(_newUsedAmount) != 0) {
                                    description = description +
                                            detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	26642, languageId)).replace("{oldAmount}", oldUsedAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount).replace("{newUnitName}", newUnitName);
                                }
                            }
                            break;
                        case "8":
                            if (_oldTotalAmount.compareTo(_newTotalAmount) != 0) {
                                description = description +
                                        detailDesc.replace("{item}", SystemEnv.getHtmlLabelName(	355, languageId)).replace("{oldAmount}", oldUsedAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount).replace("{newUnitName}", newUnitName);
                            }
                            break;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return description;
    }
}
