package com.kingdee.shr.customer.gtiit.rpt;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Month;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.format.TextStyle;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import com.kingdee.bos.metadata.query.util.CompareType;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.kingdee.shr.customer.gtiit.util.DateTimeUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.cloudera.impala.jdbc4.internal.apache.log4j.Logger;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.base.permission.UserInfo;
import com.kingdee.eas.basedata.org.AdminOrgUnitFactory;
import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
import com.kingdee.eas.basedata.org.HROrgUnitFactory;
import com.kingdee.eas.basedata.org.HROrgUnitInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.salarytemplate.WagesChromatographyFactory;
import com.kingdee.eas.custom.salarytemplate.WagesChromatographyInfo;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.eas.util.app.ContextUtil;
import com.kingdee.eas.util.app.DbUtil;
import com.kingdee.jdbc.rowset.IRowSet;
import com.kingdee.shr.base.syssetting.context.SHRContext;
import com.kingdee.shr.base.syssetting.exception.SHRWebException;
import com.kingdee.shr.base.syssetting.web.handler.ListHandler;
import com.kingdee.shr.customer.gtiit.entity.PayAddInfo;
import com.kingdee.util.LocaleUtils;




/**
 * @author ISSUSER 可以查看所有的工资单
 */
public class AllSalaryListHandler extends ListHandler {
	Context ctx = SHRContext.getInstance().getContext();
	private static Logger logger = Logger.getLogger(AllSalaryListHandler.class);
	// map存储薪酬编码 key工资单薪酬项目存储实体类
	private static Map<String, PayAddInfo> payMap = new HashMap<>();
	// mapkey是薪酬项目编码 value是薪酬项目序号
	private static Map<String, String> serialMap = new HashMap<>();
	// 存储薪酬核算表的最后修改时间和 动态添加薪酬项目字段的数量
	private static Map<String, List<String>> countFiledMap = new HashMap<>();
	SimpleDateFormat tosdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	private String  currentYear = "";
	@Override
	protected EntityViewInfo getDefaultEntityViewInfo(HttpServletRequest request, HttpServletResponse response)
			throws SHRWebException {
		// AllSalarysInfo
		// 获取当前登录用户
		UserInfo currentUserInfo = ContextUtil.getCurrentUserInfo(ctx);
		// BOSUuid uid = currentUserInfo.getId();
		BOSUuid pid = currentUserInfo.getPerson().getId();
		String personid = pid.toString();
		// 获取当前日期
		Date nowdate = new Date();
		//获取年份
		setYearParam();
		try {
			// 先查询薪酬表和套打单据里面的数据看是否一样 一样就不需要删除，不一样就要删除重新添加
			// 查询薪酬项目
			IRowSet rs = DbUtil.executeQuery(this.ctx, this.getSql(null, personid));
			// 查询工资单套打表里的数据
			getPrinting();
			// 获取薪酬核算表的最后修改时间
			List<String> updateTimeList = getUpdateTime(rs,nowdate);
			List<String> lastTimeList = countFiledMap.get("CFLasttime");
			// 获取套打表里新增字段的数量
			List<String> filedList = countFiledMap.get("CFAddFiled");
			// 动态新增薪酬项目的统计数
			String countFiled = countFiled();
			System.out.println("countFiled"+countFiled);
			// 判断两个list里面的元素是否一样 不一样就要更新数据
			boolean isEqual = CollectionUtils.isEqualCollection(updateTimeList, lastTimeList);
			System.out.println("updateTimeList"+updateTimeList.size()+"、"+lastTimeList.size());
			if (!isEqual) {
				System.out.println("进来了判断两个list里面的元素是否一样");
				// 先删除套打表里有的数据
				deleteSql(null);
				// 获取动态添加薪酬项目单据新增数据
				getPaydata();
				getSaveData(rs, currentUserInfo, nowdate);
				updateFiled(countFiled);
			}
			// 判断薪酬项目的数量的值是否在list里面 不在就要修改数据
			else if (!filedList.contains(countFiled)) {
				System.out.println("判断薪酬项目的数量的值是否在list里面");
				// 先删除套打表里有的数据
				deleteSql(null);
				// 获取动态添加薪酬项目单据新增数据
				getPaydata();
				getSaveData(rs, currentUserInfo, nowdate);
				updateFiled(countFiled);
			}else if(checkDayisUp()){
				System.out.println("改变了参数,重新触发工资包更新");
				// 先删除套打表里有的数据
				deleteSql(null);
				// 获取动态添加薪酬项目单据新增数据
				getPaydata();
				getSaveData(rs, currentUserInfo, nowdate);
				updateFiled(countFiled);
				upDayDataDate();
			}
		} catch (BOSException e) {
			e.printStackTrace();
		}
		EntityViewInfo defaultViewInfo = new EntityViewInfo();
		FilterInfo botpFilterInfo = this.getBotpFilter(request);
		if (botpFilterInfo != null) {
			defaultViewInfo.setFilter(botpFilterInfo);
			return defaultViewInfo;
		} else {
			if (logger.isDebugEnabled()) {
				String uipk = this.getUipk();
				logger.debug("getDefaultEntityViewInfo:" + uipk);
			}

			FilterInfo defaultFilterInfo = this.getDefaultFilter(request, response);
			if (logger.isDebugEnabled()) {
				String msg = defaultFilterInfo != null ? defaultFilterInfo.toSql() : "";
				logger.debug("defaultFilterInfo:" + msg);
			}

			FilterInfo customFilterInfo = this.getCustomFilter(request, response);
			if (logger.isDebugEnabled()) {
				String msg = customFilterInfo != null ? customFilterInfo.toSql() : "";
				logger.debug("customFilterInfo:" + msg);
			}

			FilterInfo domainFilterInfo = this.getDomainFilter(request);
			if (logger.isDebugEnabled()) {
				String msg = domainFilterInfo != null ? domainFilterInfo.toSql() : "";
				logger.debug("domainFilterInfo:" + msg);
			}

			FilterInfo treeDomainFilter = this.getTreeDomainFilter(request);
			if (logger.isDebugEnabled()) {
				String msg = treeDomainFilter != null ? treeDomainFilter.toSql() : "";
				logger.debug("treeDomainFilter:" + msg);
			}

			FilterInfo fastFilter = this.getFastFilter(request);
			if (logger.isDebugEnabled()) {
				String msg = fastFilter != null ? fastFilter.toSql() : "";
				logger.debug("fastFilter:" + msg);
			}

			FilterInfo advanceFilter = this.getAdvanceFilter(request);
			if (logger.isDebugEnabled()) {
				String msg = advanceFilter != null ? advanceFilter.toSql() : "";
				logger.debug("advanceFilter:" + msg);
			}

			FilterInfo expFilter = this.getExpFilter(request);
			if (logger.isDebugEnabled()) {
				String msg = expFilter != null ? expFilter.toSql() : "";
				logger.debug("expFilter:" + msg);
			}
			FilterInfo filterInfo = new FilterInfo();

			try {
				filterInfo.mergeFilter(defaultFilterInfo, "AND");
				filterInfo.mergeFilter(customFilterInfo, "AND");
				filterInfo.mergeFilter(domainFilterInfo, "AND");
				filterInfo.mergeFilter(treeDomainFilter, "AND");
				filterInfo.mergeFilter(fastFilter, "AND");
				filterInfo.mergeFilter(advanceFilter, "AND");
				filterInfo.mergeFilter(expFilter, "AND");
			} catch (BOSException var14) {
				throw new SHRWebException(var14.getMessage(), var14);
			}
			// 获取过滤条件
			String fastFilterItems = request.getParameter("fastFilterItems");
			// if (StringUtils.isNotBlank(fastFilterItems)) {
			// // 根据前端过滤条件处理
			// getFilter(fastFilterItems, defaultViewInfo, fastFilterItems, currentUserInfo,
			// nowdate, null);
			try {
				getFilter(fastFilterItems, defaultViewInfo, personid, currentUserInfo, nowdate);
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				getFilter(fastFilterItems, defaultViewInfo, personid, currentUserInfo, nowdate);
			} catch (JSONException e) {
				throw new RuntimeException(e);
			}
			logger.error("执行成功3");


			// defaultViewInfo.setFilter(filterInfo);
			if (logger.isDebugEnabled()) {
				String msg = defaultViewInfo != null ? defaultViewInfo.toString() : "";
				logger.debug("defaultViewInfo:" + msg);
			}

			return defaultViewInfo;
		}
	}

	/**
	 * 存储薪酬核算表里面的最后修改时间
	 *
	 */
	public List<String> getUpdateTime(IRowSet rs,Date nowdate) {
		List<String> updateTimeList = new ArrayList<>();
	    try {
	        if (rs.next()) {
				String formatDate = tosdf.format(nowdate);
				String flastupdatetime =  rs.getString("flastupdatetime");
				// 如果为空默认当天
				if(StringUtils.isBlank(flastupdatetime)) {
					flastupdatetime=formatDate;
				}
				// 包含.的字符串中去掉.及其后面的部分
				String replaceAll = flastupdatetime.replaceAll("\\..*", "");
				updateTimeList.add(replaceAll);
			}

		} catch (SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return updateTimeList;
	}

	/**
	 * 查询套打单据里面的数据 存储薪酬核算表的最后修改时间 和新增薪酬项目字段的数量
	 */
	public void getPrinting() {
		List<String> lastTimeList = new ArrayList<>();
		List<String> filedList = new ArrayList<>();
		String sql = "SELECT  top 1 * FROM CT_SAL_WagesChromatography order by flastupdatetime desc";
		IRowSet rs = null;
		try {
			rs = DbUtil.executeQuery(this.ctx, sql);
			while (rs.next()) {
				String lasttime = rs.getString("CFLasttime") == null ? "2023-01-01" : rs.getString("CFLasttime");
				lastTimeList.add(lasttime);
				String countFiled = rs.getString("CFAddFiled") == null ? "0" : rs.getString("CFAddFiled");
				filedList.add(countFiled);
			}
			// 薪酬核算表的最后修改时间
			countFiledMap.put("CFLasttime", lastTimeList);
			// 动态新增薪酬项目的统计数
			countFiledMap.put("CFAddFiled", filedList);
		} catch (BOSException | SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
	}

	/**
	 * 处理查询薪酬的语句
	 *
	 * @param date
	 * @param peronid
	 * @return
	 */
	public String getSql(String date, String peronid) {
		StringBuffer sql = new StringBuffer();

		String attendancenumber = "GT004";
		String curreynumber = "GT003";
		String monthnumber = "GT001";
		String grossnumber = "GT092";
		String beforeTaxnumber = "GT023";
		String servicenumber = "GT096";
		String hoursnumber = "GT090";
		String workernumber = "GT091";
		String incomebeforenumber = "GT213";
		String ytdtaxnumber = "GT217";
		String netpaymentnumber = "GT219";
		String allowanceIdnumber = "GT009";
		String workdayOTPaymentnumber = "GT005";
		String weekendOTPaymentnumber = "GT006";
		String subsidynumber = "GT016";
		String socialinsurancenumber = "GT039";
		String sedicalinsurancenumber = "GT040";
		String housingfundnumber = "GT041";
		String individualIncomeTaxnumber = "GT054";
		String insuranceplannumber = "GT215";

		// RMB
		String zfcurreyCode = "GT173";
		String positionAllowanceRMBCode = "GT109";
		String subsidyRMBCode = "GT115";
		String socialinsuranceRMBCode = "GT183";
		String medicalinsuranceRMBCode = "GT128";
		String housingfundRMBCode = "GT129";
		String netPaymentCode = "GT057";

		// 新加字段
		// GT002 Tax Exemption是否免税
		String taxExemption = "GT002";
		// GT007 Holiday OT Payment法定假加班费
		String holidayOTPayment = "GT007";
		// GT008 OT Payment总加班费
		String oTPayment = "GT008";
		// GT010 Communication Allowance通讯补贴
		String communicationAllowance = "GT010";
		// GT011 House Allowance 住房补贴
		String houseAllowance = "GT011";
		// GT012 Pension Allowance养老金补贴
		String pensionAllowance = "GT012";
		// GT035 Taxable Item计税不计薪
		String taxableItem = "GT035";
		// GT042 Special expense deductionsfor tax个税专项扣除
		String specialexpense = "GT042";
		// GT045 Annual Bonus1年终奖（按全年一次性所得计税）
		String annualBonus1 = "GT045";
		// GT048 Foreigner Annual Bonus 外籍年终奖（按一次性所得计税）
		String foreignerAnnual = "GT048";
		// GT051 Annual Bonus2年终奖（与当月薪资合并计税）
		String annualBonuss = "GT051";
		// GT052 Bonus Tax1全年一次性所得税
		String bonusTax = "GT052";
		// GT053 Bonus Tax for Non-Resident（外籍全年一次性所得税）
		String nonResident = "GT053";
		// GT055 Severance Tax经济补偿金税
		String severanceTax = "GT055";
		// GT056 Total Tax个税总计
		String totalTax = "GT056";
		// GT061 ER Social ins.单位社保
		String eRSocialins = "GT061";
		// GT062 ER Medical ins.单位综合医保险
		String eRMedicalins = "GT062";
		// GT063 ER Housing单位公积金
		String eRHousing = "GT063";
		// GT076 Payment in lieu of annual leave 年休假补偿费
		String annualleave = "GT076";
		// GT077 One-off severance pay一次性经济补偿
		String severancepay = "GT077";
		// GT222 Personal leave allowance事假补款
		String leaveallowance = "GT222";
		// GS020 Department 部门
		String department = "GS020";
		// GS021 Staff No. 工号
		String staff = "GS021";
		// GS022 Name 姓名
		String name = "GS022";
		// GS025 Nationality 国籍
		String nationality = "GS025";
		// GT191 ID No. /Passport No. 身份证号码/护照号码
		String iDno = "GT191";
		// GT094 Daily Wage日薪
		String dailyWage = "GT094";
		// GT095 Gross Wage2总日薪
		String grossWage2 = "GT095";
		// GT013 Tutoring Allowance辅导津贴
		String tutoringAllowance = "GT013";
		// GT014 Tutoring Allowance-2分摊辅导津贴
		String tutoringAllowances = "GT014";
		// GT017 Teachers Day Allowance 教师节慰问金
		String teachersDayAllowance = "GT017";
		// GT020 Total Allowance津贴总计
		String totalAllowance = "GT020";
		// GT027 Deduction Before Tax（-）税前扣款项
		String deductionBeforeTax = "GT027";
		// GT028 Total Deduction Before Tax税前扣款项合计
		String totalDeductionBeforeTax = "GT028";
		// GT031 Taxable Commercial Insurance 计税商业保险
		String taxableCommercial = "GT031";
		// GT034 Taxable Other Benefit计税其它福利
		String taxableOtherBenefit = "GT034";
		// GT018 Admission Subsidy招生津贴
		String admissionSubsidy = "GT018";
		// GT176 UG SubsidyUG补贴
		String uGSubsidyUG = "GT176";
		// GT024 Unpaid Leave Deduction 事假扣款
		String unpaidLeaveDeduction = "GT024";
		// GT066 OPT-Other Refund 其他退款
		String otherRefund = "GT066";
		// GT067 OPT-Other Deduction(-)其他扣款
		String otherDeduction = "GT067";
		// GT068 Total Rental and Utility fee房租水电费总计
		String utilityfee = "GT068";
		// GT097 Refund for rent or utility房租或水电费退款
		String rentorutility = "GT097";
		// GT036 Gross Salary 应发工资合计
		String grossSalary = "GT036";
		// GT064 Rent(-)房租
		String rent = "GT064";
		// GT065 Utility Cost(-)水电气费用
		String utilityCost = "GT065";
		// GT069 Salary Advance预支工资还款
		String salaryAdvance = "GT069";
		// GT072 Payment after Tax 税后补款项
		String paymentafterTax = "GT072";
		// GT075 Deduction after Tax（-）税后扣款项
		String deductionafterTax = "GT075";
		// GT078 Note 备注
		String note = "GT078";
		// GT042 个税专项扣除
		String deductionsfortax = "GT042";
		// GT130 个税专项扣除RMB
		// String deductionsfortaxRMB = "GT130";
		// 获取序号
		Map<String, String> fieldsnMap = getFieldsn();
		String toattendancenumber = fieldsnMap.get(attendancenumber);
		// curreynumber
		String totoattendancenumber = fieldsnMap.get(curreynumber);
		String tomonthnumber = fieldsnMap.get(monthnumber);
		String togrossnumber = fieldsnMap.get(grossnumber);
		String tobeforeTaxnumber = fieldsnMap.get(beforeTaxnumber);
		String toservicenumber = fieldsnMap.get(servicenumber);
		String tohoursnumber = fieldsnMap.get(hoursnumber);
		String toworkernumber = fieldsnMap.get(workernumber);
		String toincomebeforenumber = fieldsnMap.get(incomebeforenumber);
		String toytdtaxnumber = fieldsnMap.get(ytdtaxnumber);
		String tonetpaymentnumber = fieldsnMap.get(netpaymentnumber);
		String toallowanceIdnumber = fieldsnMap.get(allowanceIdnumber);
		String toworkdayOTPaymentnumber = fieldsnMap.get(workdayOTPaymentnumber);
		String toweekendOTPaymentnumber = fieldsnMap.get(weekendOTPaymentnumber);
		String tosubsidynumber = fieldsnMap.get(subsidynumber);
		String tosocialinsurancenumber = fieldsnMap.get(socialinsurancenumber);
		String tosedicalinsurancenumber = fieldsnMap.get(sedicalinsurancenumber);
		String tohousingfundnumber = fieldsnMap.get(housingfundnumber);
		String toindividualIncomeTaxnumber = fieldsnMap.get(individualIncomeTaxnumber);
		String toinsuranceplannumber = fieldsnMap.get(insuranceplannumber);
		// RMB
		String tozfcurreyCode = fieldsnMap.get(zfcurreyCode);
		String topositionAllowanceRMBCode = fieldsnMap.get(positionAllowanceRMBCode);
		String tosubsidyRMBCode = fieldsnMap.get(subsidyRMBCode);
		String tosocialinsuranceRMBCode = fieldsnMap.get(socialinsuranceRMBCode);
		String tomedicalinsuranceRMBCode = fieldsnMap.get(medicalinsuranceRMBCode);
		String tohousingfundRMBCode = fieldsnMap.get(housingfundRMBCode);
		String tonetPaymentCode = fieldsnMap.get(netPaymentCode);
		// 新加的薪酬项目
		String totaxExemption = fieldsnMap.get(taxExemption);
		String toholidayOTPayment = fieldsnMap.get(holidayOTPayment);
		String tooTPayment = fieldsnMap.get(oTPayment);
		String tocommunicationAllowance = fieldsnMap.get(communicationAllowance);
		String tohouseAllowance = fieldsnMap.get(houseAllowance);
		String topensionAllowance = fieldsnMap.get(pensionAllowance);
		String totaxableItem = fieldsnMap.get(taxableItem);
		String tospecialexpense = fieldsnMap.get(specialexpense);
		String toannualBonus1 = fieldsnMap.get(annualBonus1);
		String toforeignerAnnual = fieldsnMap.get(foreignerAnnual);
		String toannualBonuss = fieldsnMap.get(annualBonuss);
		String tobonusTax = fieldsnMap.get(bonusTax);
		String tononResident = fieldsnMap.get(nonResident);
		String toseveranceTax = fieldsnMap.get(severanceTax);
		String tototalTax = fieldsnMap.get(totalTax);
		String toeRSocialins = fieldsnMap.get(eRSocialins);
		String toeRMedicalins = fieldsnMap.get(eRMedicalins);
		String toeRHousing = fieldsnMap.get(eRHousing);
		String toannualleave = fieldsnMap.get(annualleave);
		String toseverancepay = fieldsnMap.get(severancepay);
		String toleaveallowance = fieldsnMap.get(leaveallowance);
		String todepartment = fieldsnMap.get(department);
		String tostaff = fieldsnMap.get(staff);
		String toname = fieldsnMap.get(name);
		String tonationality = fieldsnMap.get(nationality);
		String toiDno = fieldsnMap.get(iDno);
		String todailyWage = fieldsnMap.get(dailyWage);
		String togrossWage2 = fieldsnMap.get(grossWage2);
		String totutoringAllowance = fieldsnMap.get(tutoringAllowance);
		String totutoringAllowances = fieldsnMap.get(tutoringAllowances);
		String toteachersDayAllowance = fieldsnMap.get(teachersDayAllowance);
		String tototalAllowance = fieldsnMap.get(totalAllowance);
		// 税前扣款项
		String todeductionBeforeTax = fieldsnMap.get(deductionBeforeTax);
		String tototalDeductionBeforeTax = fieldsnMap.get(totalDeductionBeforeTax);
		String totaxableCommercial = fieldsnMap.get(taxableCommercial);
		String totaxableOtherBenefit = fieldsnMap.get(taxableOtherBenefit);
		String toadmissionSubsidy = fieldsnMap.get(admissionSubsidy);
		String touGSubsidyUG = fieldsnMap.get(uGSubsidyUG);
		String tounpaidLeaveDeduction = fieldsnMap.get(unpaidLeaveDeduction);
		String tootherRefund = fieldsnMap.get(otherRefund);
		String tootherDeduction = fieldsnMap.get(otherDeduction);
		String toutilityfee = fieldsnMap.get(utilityfee);
		String torentorutility = fieldsnMap.get(rentorutility);
		String togrossSalary = fieldsnMap.get(grossSalary);
		String torent = fieldsnMap.get(rent);
		String toutilityCost = fieldsnMap.get(utilityCost);
		String tosalaryAdvance = fieldsnMap.get(salaryAdvance);
		String topaymentafterTax = fieldsnMap.get(paymentafterTax);
		String todeductionafterTax = fieldsnMap.get(deductionafterTax);
		String tonote = fieldsnMap.get(note);

		String todeductionsfortax = fieldsnMap.get(deductionsfortax);
		// 获取新加的薪酬项目
		getSerial();
		sql.append("SELECT a.fid as personid,a.fname_l2   as personName, a.fnumber "  
				+ " as personNumber, b.FCalTime,b.FCalState as calstatus, b.FPeriodYear as countyear,b.FPeriodMonth as countmonth,b.FBeginDate as starttime,b.FEndDate as endtime,b.FCmpPeriodType as cmpertype,b.FIsLockOtherSysData as locke,\r\n"
				+ "c.FNumber as gznumber,c.FName_l2 as gzname,d.FNumber as nsNumber ,d.FTaxNumber,d.FName_l2 as nsName,d.FState as nsstatus,b."
				+ tonationality + " as guoji,b." + todepartment + " as bumenName,b." + toattendancenumber
				+ " as Attendancedays,b." + totoattendancenumber + " as ffPaymentcurrency,\r\n" + "b." + tomonthnumber
				+ " as Monthlysalary,b." + togrossnumber + " as GrossWage,b." + tobeforeTaxnumber
				+ " as PaymentbeforeTax,\r\n" + "b." + toservicenumber + " as ServiceTax,b." + tohoursnumber
				+ " as HourlyRate,b." + toworkernumber
				+ " as WorkingHours,b.fhrorgunitid as hrid,b.fadminorgunitid as orgid,b." + toincomebeforenumber
				+ " as incomebeforetax,b." + toytdtaxnumber + " as ytdtax ,b." + tonetpaymentnumber
				+ " as netpayment,b." + toallowanceIdnumber + " as allowance,b." + toworkdayOTPaymentnumber
				+ " as workdayOTPayment,\r\n" + "b." + toweekendOTPaymentnumber + " as weekendOTPayment,b."
				+ tosubsidynumber + " as subsidy ,b." + tosocialinsurancenumber + " as socialinsurance,b."
				+ tosedicalinsurancenumber + " as sedicalinsurance ,b." + tohousingfundnumber + " as housingfund , b."
				+ toindividualIncomeTaxnumber + " as individualIncomeTax ,b." + toinsuranceplannumber

				+ " as insuranceplan,b." + toiDno + " as idno,\r\n" + "b." + tozfcurreyCode + " as zfCurrency," + "\r\n"
				+ "b." + topositionAllowanceRMBCode + " as PositionAllowanceRMB," + "b." + tosubsidyRMBCode
				+ " as SubsidyRMB, b." + tosocialinsuranceRMBCode + " as SocialinsuranceRMB,b."
				+ tomedicalinsuranceRMBCode + " as MedicalinsuranceRMB,b." + tohousingfundRMBCode
				+ " as HousingfundRMB,\r\n" + "b." + tonetPaymentCode + " as tonetPayments,"
				// 新加字段
				+ "b." + totaxExemption + " as TaxExemption,b." + toholidayOTPayment + " as HolidayOTPayment,b."
				+ tooTPayment + " as OTPayment,b." + tocommunicationAllowance + " as CommunicationAllowance," + "b."
				+ tohouseAllowance + " as HouseAllowance,b." + topensionAllowance + " as PensionAllowance,b."
				+ totaxableItem + " as TaxableItem,b." + tospecialexpense + " as Specialexpense," + "b."
				+ toannualBonus1 + " as AnnualBonus1,b." + toforeignerAnnual + " as ForeignerAnnual,b." + toannualBonuss
				+ " as AnnualBonus2,b." + tobonusTax + " as BonusTax1,b." + tononResident + " as NonResident," + "b."
				+ toseveranceTax + " as SeveranceTax,b." + tototalTax + " as TotalTax,b." + toeRSocialins
				+ " as ERSocialins,b." + toeRMedicalins + " as ERMedicalins,b." + toeRHousing + " as ERHousing,b."
				+ toannualleave + " as annualleave," + "b." + toseverancepay + " as severancepay,b." + toleaveallowance
				+ " as leaveallowance,b." + todailyWage + " as DailyWage,b." + togrossWage2 + " as GrossWage2,b."
				+ totutoringAllowance + " as TutoringAllowance," + "b." + totutoringAllowances
				+ " as TutoringAllowance2,b." + toteachersDayAllowance + " as TeachersDayAllowance,b."
				+ tototalAllowance + " as TotalAllowance,b." + todeductionBeforeTax + " as DeductionBeforeTax," + "b."
				+ tototalDeductionBeforeTax + " as TotalDeductionBeforeTax,b." + totaxableCommercial
				+ " as TaxableCommercial,b." + totaxableOtherBenefit + " as TaxableOtherBenefit," + "b."
				+ toadmissionSubsidy + " as AdmissionSubsidy,b." + touGSubsidyUG + " as UGSubsidyUG,b."
				+ tounpaidLeaveDeduction + " as UnpaidLeaveDeduction,b." + tootherRefund + " as OtherRefund," + "b."
				+ tootherDeduction + " as OtherDeduction,b." + toutilityfee + " as Utilityfee,b." + torentorutility
				+ " as rentorutility,b." + togrossSalary + " as GrossSalary," + "b." + torent + " as Rent,b."
				+ toutilityCost + " as UtilityCost,b." + tosalaryAdvance + " as SalaryAdvance,b." + topaymentafterTax
				+ " as PaymentafterTax," + "b." + todeductionafterTax + " as DeductionafterTax,b." + tonote
				+ " as Note," + "b." + todeductionsfortax + " as deductionsfortax,b.flastupdatetime");

		// 遍历serialMap 拼接
		if (!serialMap.isEmpty()) {
			sql.append(",");
			for (Map.Entry<String, String> entry : serialMap.entrySet()) {
				String value = entry.getValue();
				sql.append("b.");
				sql.append(value);
				sql.append(",");
			}
			// 删除最后一个逗号
			sql.deleteCharAt(sql.length() - 1);
		}
		sql.append(
				" FROM t_bd_person a right join T_HR_SCMPCALTABLE b on a.fid=b.fpersonid  left join  T_HR_SCalScheme c on  b.FCalSchemeID=c.fid left join T_HR_TaxUnit d on c.FTaxUnitID =d.fid\r\n"
						+ "left join T_BD_Nationality e on a.FNationalityID=e.fid  left join T_ORG_BaseUnit g on b.FAdminOrgUnitID=g.fid\r\n");
		sql.append(" where 1=1 ");
		sql.append(" and b.FCalState in('12','20')   ");
		//// sql.append(" and b.fpersonid=" + "'" + peronid + "'");

		// coyle 20250430改
		String previousYear = LocalDate.now().minusYears(1).format(DateTimeFormatter.ofPattern("yyyy"));
		//取今年与去年12月的数据就可以了
		sql.append(" and ((b.fperiodyear = '" + previousYear + "' and b.fperiodmonth = '12') or ");
		sql.append("(b.fperiodyear = '" + currentYear + "')) ");

		//order  by
		sql.append("  order by flastupdatetime desc   ");
		System.out.print("所有薪酬查询语句是" + sql.toString());
		logger.error("所有薪酬查询语句是" + sql.toString());
		return sql.toString();

	}

	// 删除套打里面的有的数据sql
	public void deleteSql(String personid) throws BOSException {
		// 获取当前年份
		String previousYear = LocalDate.now().minusYears(1).format(DateTimeFormatter.ofPattern("yyyy"));
		// 准备SQL语句
		String sql = "DELETE FROM CT_SAL_WagesChromatography WHERE cfstatisticalyear = ? OR (cfstatisticalmonth = '12' AND cfstatisticalyear = ?)";
		// 打印SQL语句
		logger.error("薪酬套打的删除语句是 " + sql);
		// 执行SQL语句
		DbUtil.execute(this.ctx, sql, new Object[]{currentYear, previousYear});
	}


	// 通过编码查询薪酬字段序号的方法
	public Map<String, String> getFieldsn() {
		Map<String, String> filedMap = new HashMap<>();
		StringBuffer xincSql = new StringBuffer();
		xincSql.append("SELECT * FROM T_HR_SCmpItem where FNumber in");
		xincSql.append("('GT004','GT003','GT173','GT001','GT092','GT023','GT096','GT090',");
		xincSql.append(
				"'GT091','GT213','GT217','GT219','GT009','GT005','GT006','GT016','GT039','GT040','GT041','GT054',");
		xincSql.append("'GT215','GT193','GT205','GT118','GT208','GT204','GT109',");
		xincSql.append("'GT105','GT106','GT115','GT183','GT128','GT129','GT135','GT057',");
		// 新加薪酬项目
		xincSql.append("'GT002','GT007','GT008','GT010','GT011','GT012','GT035','GT042','GT045','GT048',");
		xincSql.append("'GT051','GT052','GT053','GT055','GT056','GT061','GT062','GT063','GT076','GT077',");
		xincSql.append("'GT222','GS020','GS021','GS022','GS025','GT191','GT094','GT095','GT013','GT014',");
		xincSql.append("'GT017','GT020','GT027','GT028','GT031','GT034','GT018','GT176','GT024','GT066',");
		xincSql.append("'GT067','GT068','GT097','GT036','GT064','GT065','GT069','GT072','GT075','GT078',");
		xincSql.append("'GT042','GT130'");
		xincSql.append(")");
		System.out.println("薪酬编码的sql是" + xincSql.toString());
		try {
			IRowSet xinrs = DbUtil.executeQuery(this.ctx, xincSql.toString());
			while (xinrs.next()) {
				filedMap.put(xinrs.getString("FNumber"), "s" + xinrs.getString("FieldSn"));
			}
		} catch (BOSException | SQLException e) {
			e.printStackTrace();
		}
		return filedMap;
	}

	/***
	 * 获取月份的英文简写名称
	 */
	public String getMonth(String month) {
		int intMonth = Integer.parseInt(month);
		Month monthEnum = Month.of(intMonth);
		String monthName = monthEnum.getDisplayName(TextStyle.SHORT, Locale.ENGLISH);

		return monthName;
	}

	/***
	 * 保存数据到工资单表里
	 */
	public void getSaveData(IRowSet rs, UserInfo currentUserInfo, Date nowdate) {

		try {
			StringBuffer xincSql = new StringBuffer();
			xincSql.append("SELECT * FROM T_HR_SCmpItem where FNumber in");
			xincSql.append("('GT004','GT003','GT173','GT001','GT092','GT023','GT096','GT090',");
			xincSql.append(
					"'GT091','GT213','GT217','GT219','GT009','GT005','GT006','GT016','GT039',' GT040','GT041','GT054',");
			xincSql.append("'GT215','GT193','GT205','GT118','GT208','GT204','GT109',");
			xincSql.append("'GT105','GT106','GT115','GT183','GT128','GT129','GT135','GT057')");
			IRowSet xinrs = DbUtil.executeQuery(this.ctx, xincSql.toString());
			String attendanceID = null;
			String curreyId = null;
			String monthId = null;
			String grossid = null;
			String beforeTaxId = null;
			String serviceID = null;
			String hoursId = null;
			String workerID = null;
			String incomebeforeId = null;
			String ytdtaxId = null;
			String netpaymentId = null;
			String allowanceId = null;
			String workdayOTPaymentId = null;
			String weekendOTPaymentId = null;
			String subsidyId = null;
			String socialinsuranceId = null;
			String sedicalinsuranceId = null;
			String housingfundId = null;
			String individualIncomeTaxId = null;
			String insuranceplanId = null;

			String attendancenumber = "GT004";
			// String curreynumber = "GT003";
			String monthnumber = "GT001";
			String grossnumber = "GT092";
			String beforeTaxnumber = "GT023";
			String servicenumber = "GT096";
			String hoursnumber = "GT090";
			String workernumber = "GT091";
			String incomebeforenumber = "GT213";
			String ytdtaxnumber = "GT217";
			String netpaymentnumber = "GT219";
			String allowanceIdnumber = "GT009";
			String workdayOTPaymentnumber = "GT005";
			String weekendOTPaymentnumber = "GT006";
			String subsidynumber = "GT016";
			String socialinsurancenumber = "GT039";
			String sedicalinsurancenumber = "GT040";
			String housingfundnumber = "GT041";
			String individualIncomeTaxnumber = "GT054";
			String insuranceplannumber = "GT215";

			// RMB
			// String zfcurreyCode = "GT173";
			String monthRMBCode = "GT193";
			String grossWageRMBCode = "GT205";
			String paymentbeforeRMBCode = "GT118";
			String serviceTaxRMBCode = "GT208";
			String hourlyRateRMBCode = "GT204";
			String positionAllowanceRMBCode = "GT109";
			String WorkdayOTPaymentRMBCode = "GT105";
			String weekendOTPaymentRMBCode = "GT106";
			String subsidyRMBCode = "GT115";
			String socialinsuranceRMBCode = "GT183";
			String medicalinsuranceRMBCode = "GT128";
			String housingfundRMBCode = "GT129";
			String socialinsuranceplanRMBCode = "GT214";

			// 实发工资 GT057
			String netPaymentCode = "GT057";
			while (xinrs.next()) {
				String number = xinrs.getString("FNumber");
				// 发放币种
				if (number.equals("GT003")) {
					curreyId = xinrs.getString("fid");
				}
				// 出勤天数
				if (number.equals("GT004")) {
					attendanceID = xinrs.getString("fid");
					attendancenumber = number;
				}
				// 月薪
				if (number.equals("GT001")) {
					monthId = xinrs.getString("fid");
					monthnumber = number;
				}
				// 总时薪
				if (number.equals("GT092")) {
					grossid = xinrs.getString("fid");
					grossnumber = number;
				}
				// 税前补款项
				if (number.equals("GT023")) {
					beforeTaxId = xinrs.getString("fid");
					beforeTaxnumber = number;
				}
				// 劳务税
				if (number.equals("GT096")) {
					serviceID = xinrs.getString("fid");
					servicenumber = number;
				}
				// 时薪
				if (number.equals("GT090")) {
					hoursId = xinrs.getString("fid");
					hoursnumber = number;
				}
				// 工作小时数
				if (number.equals("GT091")) {
					workerID = xinrs.getString("fid");
					workernumber = number;
				}
				// 年至今税前总工资
				if (number.equals("GT213")) {
					incomebeforeId = xinrs.getString("fid");
					incomebeforenumber = number;
				}
				// 年至今个人所得税
				if (number.equals("GT217")) {
					ytdtaxId = xinrs.getString("fid");
					ytdtaxnumber = number;
				}
				// 年至今实发工资
				if (number.equals("GT219")) {
					netpaymentId = xinrs.getString("fid");
					netpaymentnumber = number;
				}
				// 岗位津贴
				if (number.equals("GT009")) {
					allowanceId = xinrs.getString("fid");
					allowanceIdnumber = number;
				}
				// 平日加班费
				if (number.equals("GT005")) {
					workdayOTPaymentId = xinrs.getString("fid");
					workdayOTPaymentnumber = number;
				}
				// 休息日加班费
				if (number.equals("GT006")) {
					weekendOTPaymentId = xinrs.getString("fid");
					weekendOTPaymentnumber = number;
				}
				// 高温补贴
				if (number.equals("GT016")) {
					subsidyId = xinrs.getString("fid");
					subsidynumber = number;
				}
				// 社保
				if (number.equals("GT039")) {
					socialinsuranceId = xinrs.getString("fid");
					socialinsurancenumber = number;
				}
				// 医保
				if (number.equals("GT040")) {
					sedicalinsuranceId = xinrs.getString("fid");
					sedicalinsurancenumber = number;
				}
				// 公积金
				if (number.equals("GT041")) {
					housingfundId = xinrs.getString("fid");
					housingfundnumber = number;
				}
				// 个人所得税
				if (number.equals("GT054")) {
					individualIncomeTaxId = xinrs.getString("fid");
					individualIncomeTaxnumber = number;
				}
				// 年至今社医保公积金
				if (number.equals("GT215")) {
					insuranceplanId = xinrs.getString("fid");
					insuranceplannumber = number;
				}

			}
			CoreBaseCollection collection = new CoreBaseCollection();
			// rs
			rs.beforeFirst();
			while (rs.next()) {
				// StringBuffer inertSql = new StringBuffer();
				// 部门id
				String drementid = rs.getString("orgid");
				// hr组织id
				String hrID = rs.getString("hrid");
				// 人员id
				String topersonid = rs.getString("personid") == null ? "" : rs.getString("personid");
				// 姓名
				String personName = rs.getString("personName") == null ? "" : rs.getString("personName");
				// 工号
				String personNumber = rs.getString("personNumber") == null ? "" : rs.getString("personNumber");
				// 核算次
				String fCalTime = rs.getString("FCalTime") == null ? "" : rs.getString("FCalTime");
				// 核算状态
				String calstatus = rs.getString("calstatus") == null ? "" : rs.getString("calstatus");
				// 统计年
				String countyear = rs.getString("countyear") == null ? "" : rs.getString("countyear");
				// 统计月
				String countmonth = rs.getString("countmonth") == null ? "" : rs.getString("countmonth");
				// 起始时间
				String tostarttime = rs.getString("starttime") == null ? "" : rs.getString("starttime");
				// 结束时间
				String endtime = rs.getString("endtime") == null ? "" : rs.getString("endtime");
				// // 结账周期
				// String cmpertype = rs.getString("cmpertype") == null ? "" :
				// rs.getString("cmpertype");
				// 是否锁
				String locke = rs.getString("locke") == null ? "" : rs.getString("locke");
				// 计算规则编码
				String gznumber = rs.getString("gznumber") == null ? "" : rs.getString("gznumber");
				// 计算规则名称
				String gzname = rs.getString("gzname") == null ? "" : rs.getString("gzname");
				// 国籍
				String guoji = rs.getString("guoji") == null ? "" : rs.getString("guoji");
				// 部门
				String bumenName = rs.getString("bumenName") == null ? "" : rs.getString("bumenName");
				// 出勤天数
				BigDecimal bigAttendancedays = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("Attendancedays"))
						&& StringUtils.isNotBlank(rs.getString("Attendancedays"))) {
					bigAttendancedays = rs.getBigDecimal("Attendancedays").setScale(2, RoundingMode.HALF_UP);
				}
				String Attendancedays = bigAttendancedays.toString();
				// 发放币别
				String ffPaymentcurrency = rs.getString("ffPaymentcurrency") == null ? ""
						: rs.getString("ffPaymentcurrency");
				// 月薪
				BigDecimal bigmonth = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("Monthlysalary"))
						&& StringUtils.isNotBlank(rs.getString("Monthlysalary"))) {
					bigmonth = rs.getBigDecimal("Monthlysalary").setScale(2, RoundingMode.HALF_UP);
				}
				String monthlysalary = bigmonth.toString();
				// 总时薪 40.00000
				BigDecimal bigGrossWage = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("GrossWage")) && StringUtils.isNotBlank(rs.getString("GrossWage"))) {
					bigGrossWage = rs.getBigDecimal("GrossWage").setScale(2, RoundingMode.HALF_UP);
				}
				String grossWage = bigGrossWage.toString();
				// 税前补款项
				BigDecimal bigPaymentbeforeTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("PaymentbeforeTax"))
						&& StringUtils.isNotBlank(rs.getString("PaymentbeforeTax"))) {
					bigPaymentbeforeTax = rs.getBigDecimal("PaymentbeforeTax").setScale(2, RoundingMode.HALF_UP);
				}
				String paymentbeforeTax = bigPaymentbeforeTax.toString();
				// 劳务税
				BigDecimal bigServiceTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("ServiceTax"))
						&& StringUtils.isNotBlank(rs.getString("ServiceTax"))) {
					bigServiceTax = rs.getBigDecimal("ServiceTax").setScale(2, RoundingMode.HALF_UP);
				}
				String serviceTax = bigServiceTax.toString();
				// 时薪
				BigDecimal bigHourlyRate = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("HourlyRate"))
						&& StringUtils.isNotBlank(rs.getString("HourlyRate"))) {
					bigHourlyRate = rs.getBigDecimal("HourlyRate").setScale(2, RoundingMode.HALF_UP);
				}
				String hourlyRate = bigHourlyRate.toString();

				// 工作小时数
				BigDecimal bigworkingHours = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("WorkingHours"))
						&& StringUtils.isNotBlank(rs.getString("WorkingHours"))) {
					bigworkingHours = rs.getBigDecimal("WorkingHours").setScale(2, RoundingMode.HALF_UP);
				}
				String workingHours = bigworkingHours.toString();
				// 年至今税前总工资
				BigDecimal bigincomebeforetax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("incomebeforetax"))
						&& StringUtils.isNotBlank(rs.getString("incomebeforetax"))) {
					bigincomebeforetax = rs.getBigDecimal("incomebeforetax").setScale(2, RoundingMode.HALF_UP);
				}
				String incomebeforetax = bigincomebeforetax.toString();
				// 年至今个人所得税
				BigDecimal bigytdtax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("ytdtax")) && StringUtils.isNotBlank(rs.getString("ytdtax"))) {
					bigytdtax = rs.getBigDecimal("ytdtax").setScale(2, RoundingMode.HALF_UP);
				}
				String ytdtax = bigytdtax.toString();
				// 年至今实发工资
				BigDecimal bignetpayment = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("netpayment"))
						&& StringUtils.isNotBlank(rs.getString("netpayment"))) {
					bignetpayment = rs.getBigDecimal("netpayment").setScale(2, RoundingMode.HALF_UP);
				}
				String netpayment = bignetpayment.toString();
				// 岗位津贴
				BigDecimal bigallowance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("allowance")) && StringUtils.isNotBlank(rs.getString("allowance"))) {
					bigallowance = rs.getBigDecimal("allowance").setScale(2, RoundingMode.HALF_UP);
				}
				String allowance = bigallowance.toString();
				// 平日加班费
				BigDecimal bigworkdayOTPayment = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("workdayOTPayment"))
						&& StringUtils.isNotBlank(rs.getString("workdayOTPayment"))) {
					bigworkdayOTPayment = rs.getBigDecimal("workdayOTPayment").setScale(2, RoundingMode.HALF_UP);
				}
				String workdayOTPayment = bigworkdayOTPayment.toString();
				// 休息日加班费
				BigDecimal bigweekendOTPayment = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("weekendOTPayment"))
						&& StringUtils.isNotBlank(rs.getString("weekendOTPayment"))) {
					bigweekendOTPayment = rs.getBigDecimal("weekendOTPayment").setScale(2, RoundingMode.HALF_UP);
				}
				String weekendOTPayment = bigweekendOTPayment.toString();
				// 高温补贴
				BigDecimal bigsubsidy = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("subsidy")) && StringUtils.isNotBlank(rs.getString("subsidy"))) {
					bigsubsidy = rs.getBigDecimal("subsidy").setScale(2, RoundingMode.HALF_UP);
				}
				String subsidy = bigsubsidy.toString();
				// 社保
				BigDecimal bigsocialinsurance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("socialinsurance"))
						&& StringUtils.isNotBlank(rs.getString("socialinsurance"))) {
					bigsocialinsurance = rs.getBigDecimal("socialinsurance").setScale(2, RoundingMode.HALF_UP);
				}
				String socialinsurance = bigsocialinsurance.toString();
				// 医保
				BigDecimal bigsedicalinsurance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("sedicalinsurance"))
						&& StringUtils.isNotBlank(rs.getString("sedicalinsurance"))) {
					bigsedicalinsurance = rs.getBigDecimal("sedicalinsurance").setScale(2, RoundingMode.HALF_UP);
				}
				String sedicalinsurance = bigsedicalinsurance.toString();
				// 公积金
				BigDecimal bighousingfund = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("housingfund"))
						&& StringUtils.isNotBlank(rs.getString("housingfund"))) {
					bighousingfund = rs.getBigDecimal("housingfund").setScale(2, RoundingMode.HALF_UP);
				}
				String housingfund = bighousingfund.toString();
				// 个人所得税
				BigDecimal bigindividualIncomeTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("individualIncomeTax"))
						&& StringUtils.isNotBlank(rs.getString("individualIncomeTax"))) {
					bigindividualIncomeTax = rs.getBigDecimal("individualIncomeTax").setScale(2, RoundingMode.HALF_UP);
				}
				String individualIncomeTax = bigindividualIncomeTax.toString();
				// 年至今社医保公积金
				BigDecimal biginsuranceplan = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("insuranceplan"))
						&& StringUtils.isNotBlank(rs.getString("insuranceplan"))) {
					biginsuranceplan = rs.getBigDecimal("insuranceplan").setScale(2, RoundingMode.HALF_UP);
				}
				String insuranceplan = biginsuranceplan.toString();
				// 身份证
				String idno = rs.getString("idno") == null ? "" : rs.getString("idno");
				// 支付币别
				String zfCurrency = rs.getString("zfCurrency");

				// RMB

				// 岗位津贴RMB
				BigDecimal bigallowanceRMB = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("PositionAllowanceRMB"))
						&& StringUtils.isNotBlank(rs.getString("PositionAllowanceRMB"))) {
					bigallowanceRMB = rs.getBigDecimal("PositionAllowanceRMB").setScale(2, RoundingMode.HALF_UP);
				}
				String allowanceRMB = bigallowanceRMB.toString();
				// 高温补贴RMB
				BigDecimal bigsubsidyRMB = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("SubsidyRMB"))
						&& StringUtils.isNotBlank(rs.getString("SubsidyRMB"))) {
					bigsubsidyRMB = rs.getBigDecimal("SubsidyRMB").setScale(2, RoundingMode.HALF_UP);
				}
				String subsidyRMB = bigsubsidyRMB.toString();
				// 社保RMB
				BigDecimal bigsocialinsuranceRMB = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("SocialinsuranceRMB"))
						&& StringUtils.isNotBlank(rs.getString("SocialinsuranceRMB"))) {
					bigsocialinsuranceRMB = rs.getBigDecimal("SocialinsuranceRMB").setScale(2, RoundingMode.HALF_UP);
				}
				String socialinsuranceRMB = bigsocialinsuranceRMB.toString();
				// 医保RMB
				BigDecimal bigsedicalinsuranceRMB = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("MedicalinsuranceRMB"))
						&& StringUtils.isNotBlank(rs.getString("MedicalinsuranceRMB"))) {
					bigsedicalinsuranceRMB = rs.getBigDecimal("MedicalinsuranceRMB").setScale(2, RoundingMode.HALF_UP);
				}
				String sedicalinsuranceRMB = bigsedicalinsuranceRMB.toString();
				// 公积金RMB
				BigDecimal bighousingfundRMB = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("HousingfundRMB"))
						&& StringUtils.isNotBlank(rs.getString("HousingfundRMB"))) {
					bighousingfundRMB = rs.getBigDecimal("HousingfundRMB").setScale(2, RoundingMode.HALF_UP);
				}
				String housingfundRMB = bighousingfundRMB.toString();

				// 实发工资 tonetPaymentCode
				BigDecimal bigtonetPayments = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("tonetPayments"))
						&& StringUtils.isNotBlank(rs.getString("tonetPayments"))) {
					bigtonetPayments = rs.getBigDecimal("tonetPayments").setScale(2, RoundingMode.HALF_UP);
				}
				String tonetPayments = bigtonetPayments.toString();

				// 新建的薪酬项目

				// Note 备注
				String note = rs.getString("Note") == null ? "" : rs.getString("Note");
				// DeductionafterTax 税后扣款项
				BigDecimal bigdeductionafterTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("DeductionafterTax"))
						&& StringUtils.isNotBlank(rs.getString("DeductionafterTax"))) {
					bigdeductionafterTax = rs.getBigDecimal("DeductionafterTax").setScale(2, RoundingMode.HALF_UP);
				}
				String deductionafterTax = bigdeductionafterTax.toString();
				// PaymentafterTax 税后补款项
				BigDecimal bigPaymentafterTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("PaymentafterTax"))
						&& StringUtils.isNotBlank(rs.getString("PaymentafterTax"))) {
					bigPaymentafterTax = rs.getBigDecimal("PaymentafterTax").setScale(2, RoundingMode.HALF_UP);
				}
				String paymentafterTax = bigPaymentafterTax.toString();
				// SalaryAdvance 预支工资还款
				BigDecimal bigSalaryAdvance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("SalaryAdvance"))
						&& StringUtils.isNotBlank(rs.getString("SalaryAdvance"))) {
					bigSalaryAdvance = rs.getBigDecimal("SalaryAdvance").setScale(2, RoundingMode.HALF_UP);
				}
				String salaryAdvance = bigSalaryAdvance.toString();
				// UtilityCost 水电气费用
				BigDecimal bigUtilityCost = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("UtilityCost"))
						&& StringUtils.isNotBlank(rs.getString("UtilityCost"))) {
					bigUtilityCost = rs.getBigDecimal("UtilityCost").setScale(2, RoundingMode.HALF_UP);
				}
				String utilityCost = bigUtilityCost.toString();
				// Rent 房租
				BigDecimal bigRent = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("Rent")) && StringUtils.isNotBlank(rs.getString("Rent"))) {
					bigRent = rs.getBigDecimal("Rent").setScale(2, RoundingMode.HALF_UP);
				}
				String rent = bigRent.toString();
				// GrossSalary 应发工资合计
				BigDecimal bigGrossSalary = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("GrossSalary"))
						&& StringUtils.isNotBlank(rs.getString("GrossSalary"))) {
					bigGrossSalary = rs.getBigDecimal("GrossSalary").setScale(2, RoundingMode.HALF_UP);
				}
				String grossSalary = bigGrossSalary.toString();
				// rentorutility 房租或水电费退款
				BigDecimal bigrentorutility = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("rentorutility"))
						&& StringUtils.isNotBlank(rs.getString("rentorutility"))) {
					bigrentorutility = rs.getBigDecimal("rentorutility").setScale(2, RoundingMode.HALF_UP);
				}
				String rentorutility = bigrentorutility.toString();
				// Utilityfee 房租水电费总计
				BigDecimal bigUtilityfee = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("Utilityfee"))
						&& StringUtils.isNotBlank(rs.getString("Utilityfee"))) {
					bigUtilityfee = rs.getBigDecimal("Utilityfee").setScale(2, RoundingMode.HALF_UP);
				}
				String utilityfee = bigUtilityfee.toString();
				// OtherDeduction 其他扣款
				BigDecimal bigOtherDeduction = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("OtherDeduction"))
						&& StringUtils.isNotBlank(rs.getString("OtherDeduction"))) {
					bigOtherDeduction = rs.getBigDecimal("OtherDeduction").setScale(2, RoundingMode.HALF_UP);
				}
				String otherDeduction = bigOtherDeduction.toString();
				// OtherRefund 其他退款
				BigDecimal bigOtherRefund = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("OtherRefund"))
						&& StringUtils.isNotBlank(rs.getString("OtherRefund"))) {
					bigOtherRefund = rs.getBigDecimal("OtherRefund").setScale(2, RoundingMode.HALF_UP);
				}
				String otherRefund = bigOtherRefund.toString();
				// UnpaidLeaveDeduction 事假扣款
				BigDecimal bigUnpaidLeaveDeduction = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("UnpaidLeaveDeduction"))
						&& StringUtils.isNotBlank(rs.getString("UnpaidLeaveDeduction"))) {
					bigUnpaidLeaveDeduction = rs.getBigDecimal("UnpaidLeaveDeduction").setScale(2,
							RoundingMode.HALF_UP);
				}
				String unpaidLeaveDeduction = bigUnpaidLeaveDeduction.toString();
				// UGSubsidyUG 补贴
				BigDecimal bigUGSubsidyUG = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("UGSubsidyUG"))
						&& StringUtils.isNotBlank(rs.getString("UGSubsidyUG"))) {
					bigUGSubsidyUG = rs.getBigDecimal("UGSubsidyUG").setScale(2, RoundingMode.HALF_UP);
				}
				String uGSubsidyUG = bigUGSubsidyUG.toString();
				// AdmissionSubsidy 招生津贴
				BigDecimal bigAdmissionSubsidy = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("AdmissionSubsidy"))
						&& StringUtils.isNotBlank(rs.getString("AdmissionSubsidy"))) {
					bigAdmissionSubsidy = rs.getBigDecimal("AdmissionSubsidy").setScale(2, RoundingMode.HALF_UP);
				}
				String admissionSubsidy = bigAdmissionSubsidy.toString();
				// TaxableOtherBenefit 计税其它福利
				BigDecimal bigTaxableOtherBenefit = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("TaxableOtherBenefit"))
						&& StringUtils.isNotBlank(rs.getString("TaxableOtherBenefit"))) {
					bigTaxableOtherBenefit = rs.getBigDecimal("TaxableOtherBenefit").setScale(2, RoundingMode.HALF_UP);
				}
				String taxableOtherBenefit = bigTaxableOtherBenefit.toString();
				// TaxableCommercial 计税商业保险
				BigDecimal bigTaxableCommercial = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("TaxableCommercial"))
						&& StringUtils.isNotBlank(rs.getString("TaxableCommercial"))) {
					bigTaxableCommercial = rs.getBigDecimal("TaxableCommercial").setScale(2, RoundingMode.HALF_UP);
				}
				String taxableCommercial = bigTaxableCommercial.toString();
				// TotalDeductionBeforeTax 税前扣款项合计
				BigDecimal bigTotalDeductionBeforeTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("TotalDeductionBeforeTax"))
						&& StringUtils.isNotBlank(rs.getString("TotalDeductionBeforeTax"))) {
					bigTotalDeductionBeforeTax = rs.getBigDecimal("TotalDeductionBeforeTax").setScale(2,
							RoundingMode.HALF_UP);
				}
				String totalDeductionBeforeTax = bigTotalDeductionBeforeTax.toString();
				// DeductionBeforeTax 税前扣款项
				BigDecimal bigDeductionBeforeTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("DeductionBeforeTax"))
						&& StringUtils.isNotBlank(rs.getString("DeductionBeforeTax"))) {
					bigDeductionBeforeTax = rs.getBigDecimal("DeductionBeforeTax").setScale(2, RoundingMode.HALF_UP);
				}
				String deductionBeforeTax = bigDeductionBeforeTax.toString();
				// TotalAllowance 津贴总计
				BigDecimal bigTotalAllowance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("TotalAllowance"))
						&& StringUtils.isNotBlank(rs.getString("TotalAllowance"))) {
					bigTotalAllowance = rs.getBigDecimal("TotalAllowance").setScale(2, RoundingMode.HALF_UP);
				}
				String totalAllowance = bigTotalAllowance.toString();
				// TeachersDayAllowance 教师节慰问金
				BigDecimal bigTeachersDayAllowance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("TeachersDayAllowance"))
						&& StringUtils.isNotBlank(rs.getString("TeachersDayAllowance"))) {
					bigTeachersDayAllowance = rs.getBigDecimal("TeachersDayAllowance").setScale(2,
							RoundingMode.HALF_UP);
				}
				String teachersDayAllowance = bigTeachersDayAllowance.toString();
				// TutoringAllowance2 分摊辅导津贴
				BigDecimal bigTutoringAllowance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("TutoringAllowance2"))
						&& StringUtils.isNotBlank(rs.getString("TutoringAllowance2"))) {
					bigTutoringAllowance = rs.getBigDecimal("TutoringAllowance2").setScale(2, RoundingMode.HALF_UP);
				}
				String tutoringAllowance = bigTutoringAllowance.toString();
				// TutoringAllowance 辅导津贴
				BigDecimal bigTutoringAllowances = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("TutoringAllowance"))
						&& StringUtils.isNotBlank(rs.getString("TutoringAllowance"))) {
					bigTutoringAllowances = rs.getBigDecimal("TutoringAllowance").setScale(2, RoundingMode.HALF_UP);
				}
				String tutoringAllowances = bigTutoringAllowances.toString();
				// GrossWage2 总日薪
				BigDecimal bigGrossWages = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("GrossWage2"))
						&& StringUtils.isNotBlank(rs.getString("GrossWage2"))) {
					bigGrossWages = rs.getBigDecimal("GrossWage2").setScale(2, RoundingMode.HALF_UP);
				}
				String grossWages = bigGrossWages.toString();
				// DailyWage 日薪
				BigDecimal bigDailyWage = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("DailyWage")) && StringUtils.isNotBlank(rs.getString("DailyWage"))) {
					bigDailyWage = rs.getBigDecimal("DailyWage").setScale(2, RoundingMode.HALF_UP);
				}
				String dailyWage = bigDailyWage.toString();
				// leaveallowance 事假补款
				BigDecimal bigleaveallowance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("leaveallowance"))
						&& StringUtils.isNotBlank(rs.getString("leaveallowance"))) {
					bigleaveallowance = rs.getBigDecimal("leaveallowance").setScale(2, RoundingMode.HALF_UP);
				}
				String leaveallowance = bigleaveallowance.toString();
				// severancepay 一次性经济补偿
				BigDecimal bigseverancepay = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("severancepay"))
						&& StringUtils.isNotBlank(rs.getString("severancepay"))) {
					bigseverancepay = rs.getBigDecimal("severancepay").setScale(2, RoundingMode.HALF_UP);
				}
				String severancepay = bigseverancepay.toString();
				// annualleave 年休假补偿费
				BigDecimal bigannualleave = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("annualleave"))
						&& StringUtils.isNotBlank(rs.getString("annualleave"))) {
					bigannualleave = rs.getBigDecimal("annualleave").setScale(2, RoundingMode.HALF_UP);
				}
				String annualleave = bigannualleave.toString();
				// ERHousing 单位公积金
				BigDecimal bigERHousing = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("ERHousing")) && StringUtils.isNotBlank(rs.getString("ERHousing"))) {
					bigERHousing = rs.getBigDecimal("ERHousing").setScale(2, RoundingMode.HALF_UP);
				}
				String eRHousing = bigERHousing.toString();
				// ERMedicalins 单位综合医保险
				BigDecimal bigERMedicalins = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("ERMedicalins"))
						&& StringUtils.isNotBlank(rs.getString("ERMedicalins"))) {
					bigERMedicalins = rs.getBigDecimal("ERMedicalins").setScale(2, RoundingMode.HALF_UP);
				}
				String eRMedicalins = bigERMedicalins.toString();
				// ERSocialins 单位社保
				BigDecimal bigERSocialins = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("ERSocialins"))
						&& StringUtils.isNotBlank(rs.getString("ERSocialins"))) {
					bigERSocialins = rs.getBigDecimal("ERSocialins").setScale(2, RoundingMode.HALF_UP);
				}
				String eRSocialins = bigERSocialins.toString();
				// TotalTax 个税总计
				BigDecimal bigTotalTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("TotalTax")) && StringUtils.isNotBlank(rs.getString("TotalTax"))) {
					bigTotalTax = rs.getBigDecimal("TotalTax").setScale(2, RoundingMode.HALF_UP);
				}
				String totalTax = bigTotalTax.toString();
				// SeveranceTax 经济补偿金税
				BigDecimal bigSeveranceTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("SeveranceTax"))
						&& StringUtils.isNotBlank(rs.getString("SeveranceTax"))) {
					bigSeveranceTax = rs.getBigDecimal("SeveranceTax").setScale(2, RoundingMode.HALF_UP);
				}
				String severanceTax = bigSeveranceTax.toString();
				// NonResident 外籍全年一次性所得税
				BigDecimal bigNonResident = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("NonResident"))
						&& StringUtils.isNotBlank(rs.getString("NonResident"))) {
					bigNonResident = rs.getBigDecimal("NonResident").setScale(2, RoundingMode.HALF_UP);
				}
				String nonResident = bigNonResident.toString();
				// BonusTax1 全年一次性所得税
				BigDecimal bigBonusTax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("BonusTax1")) && StringUtils.isNotBlank(rs.getString("BonusTax1"))) {
					bigBonusTax = rs.getBigDecimal("BonusTax1").setScale(2, RoundingMode.HALF_UP);
				}
				String bonusTax = bigBonusTax.toString();
				// AnnualBonus2 年终奖（与当月薪资合并计税）
				BigDecimal bigAnnualBonuss = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("AnnualBonus2"))
						&& StringUtils.isNotBlank(rs.getString("AnnualBonus2"))) {
					bigAnnualBonuss = rs.getBigDecimal("AnnualBonus2").setScale(2, RoundingMode.HALF_UP);
				}
				String annualBonuss = bigAnnualBonuss.toString();
				// ForeignerAnnual 外籍年终奖（按一次性所得计税
				BigDecimal bigForeignerAnnual = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("ForeignerAnnual"))
						&& StringUtils.isNotBlank(rs.getString("ForeignerAnnual"))) {
					bigForeignerAnnual = rs.getBigDecimal("ForeignerAnnual").setScale(2, RoundingMode.HALF_UP);
				}
				String foreignerAnnual = bigForeignerAnnual.toString();
				// AnnualBonus1 年终奖（按全年一次性所得计税）
				BigDecimal bigdAnnualBonus = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("AnnualBonus1"))
						&& StringUtils.isNotBlank(rs.getString("AnnualBonus1"))) {
					bigdAnnualBonus = rs.getBigDecimal("AnnualBonus1").setScale(2, RoundingMode.HALF_UP);
				}
				String annualBonus = bigdAnnualBonus.toString();
				// Specialexpense 个税专项扣除
				BigDecimal bigSpecialexpense = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("Specialexpense"))
						&& StringUtils.isNotBlank(rs.getString("Specialexpense"))) {
					bigSpecialexpense = rs.getBigDecimal("Specialexpense").setScale(2, RoundingMode.HALF_UP);
				}
				String specialexpense = bigSpecialexpense.toString();
				// TaxableItem 计税不计薪
				BigDecimal bigTaxableItem = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("TaxableItem"))
						&& StringUtils.isNotBlank(rs.getString("TaxableItem"))) {
					bigTaxableItem = rs.getBigDecimal("TaxableItem").setScale(2, RoundingMode.HALF_UP);
				}
				String taxableItem = bigTaxableItem.toString();
				// PensionAllowance 养老金补贴
				BigDecimal bigPensionAllowance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("PensionAllowance"))
						&& StringUtils.isNotBlank(rs.getString("PensionAllowance"))) {
					bigPensionAllowance = rs.getBigDecimal("PensionAllowance").setScale(2, RoundingMode.HALF_UP);
				}
				String pensionAllowance = bigPensionAllowance.toString();
				// HouseAllowance 住房补贴
				BigDecimal bigHouseAllowance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("HouseAllowance"))
						&& StringUtils.isNotBlank(rs.getString("HouseAllowance"))) {
					bigHouseAllowance = rs.getBigDecimal("HouseAllowance").setScale(2, RoundingMode.HALF_UP);
				}
				String houseAllowance = bigHouseAllowance.toString();
				// CommunicationAllowance 通讯补贴
				BigDecimal bigCommunicationAllowance = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("CommunicationAllowance"))
						&& StringUtils.isNotBlank(rs.getString("CommunicationAllowance"))) {
					bigCommunicationAllowance = rs.getBigDecimal("CommunicationAllowance").setScale(2,
							RoundingMode.HALF_UP);
				}
				String communicationAllowance = bigCommunicationAllowance.toString();
				// OTPayment 总加班费
				BigDecimal bigOTPayment = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("OTPayment")) && StringUtils.isNotBlank(rs.getString("OTPayment"))) {
					bigOTPayment = rs.getBigDecimal("OTPayment").setScale(2, RoundingMode.HALF_UP);
				}
				String oTPayment = bigOTPayment.toString();
				// HolidayOTPayment 法定假加班费
				BigDecimal bigHolidayOTPayment = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("HolidayOTPayment"))
						&& StringUtils.isNotBlank(rs.getString("HolidayOTPayment"))) {
					bigHolidayOTPayment = rs.getBigDecimal("HolidayOTPayment").setScale(2, RoundingMode.HALF_UP);
				}
				String holidayOTPayment = bigHolidayOTPayment.toString();
				// TaxExemption 是否免税
				String taxExemption = rs.getString("TaxExemption") == null ? "" : rs.getString("TaxExemption");

				// 个税专项扣除
				BigDecimal bigdeductionsfortax = new BigDecimal("0.00");
				if (!("0E-10").equals(rs.getString("deductionsfortax"))
						&& StringUtils.isNotBlank(rs.getString("deductionsfortax"))) {
					bigdeductionsfortax = rs.getBigDecimal("deductionsfortax").setScale(2, RoundingMode.HALF_UP);
				}
				String deductionsfortax = bigdeductionsfortax.toString();
				// 获取月份的第一天和最后一天 拼接工资周期字段
				int intyeardate = Integer.parseInt(countyear);
				int intmonth = Integer.parseInt(countmonth);
				YearMonth yearMonth = YearMonth.of(intyeardate, intmonth);
				LocalDate firstDayOfMonth = yearMonth.atDay(1);
				String fitstday = Integer.toString(firstDayOfMonth.getDayOfMonth());
				LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
				String lastday = Integer.toString(lastDayOfMonth.getDayOfMonth());
				// 获取月份的英文
				String month = getMonth(countmonth);
				// 工资周期的英文
				String wagsenglist = "From " + fitstday + "-" + month + "-" + countyear + " to " + lastday + "-" + month
						+ "-" + countyear;
				// 最后薪酬核算表修改的时间
				//Date flastupdatetime = rs.getDate("flastupdatetime");
				Date flastupdatetime = rs.getDate("flastupdatetime")==null ? nowdate :rs.getDate("flastupdatetime");

				// 获取新加薪酬项目的值
				Map<String, String> payVlueMap = getPayVlue(rs);

				WagesChromatographyInfo wagesInfo = new WagesChromatographyInfo();
				// socialinsuranceplanRMBCode 年至今社医保公积金RMB编码
				wagesInfo.put("socialinsuranceplanRMBCode", socialinsuranceplanRMBCode);
				// IndividualIncomeTaxRMB 个人所得税RMB金额
				// wagesInfo.put("IndividualIncomeTaxRMB", individualIncomeTaxRMB);
				// HousingfundRMB 公积金 RMB金额
				wagesInfo.put("HousingfundRMB", housingfundRMB);
				// HousingfundRMBCode 公积金RMB编码
				wagesInfo.put("HousingfundRMBCode", housingfundRMBCode);
				// MedicalinsuranceRMB 医保RMB金额
				wagesInfo.put("MedicalinsuranceRMB", sedicalinsuranceRMB);
				// MedicalinsuranceRMBCode 医保RMB编码
				wagesInfo.put("MedicalinsuranceRMBCode", medicalinsuranceRMBCode);
				// SocialinsuranceRMB 社保RMB金额
				wagesInfo.put("SocialinsuranceRMB", socialinsuranceRMB);
				// SocialinsuranceRMBCode 社保RMB编码
				wagesInfo.put("SocialinsuranceRMBCode", socialinsuranceRMBCode);
				// SubsidyRMB 高温补贴RMB金额
				wagesInfo.put("SubsidyRMB", subsidyRMB);
				// SubsidyRMBCode 高温补贴RMB编码
				wagesInfo.put("SubsidyRMBCode", subsidyRMBCode);
				// WeekendOTPaymentRMBCode 休息日加班费RMB编码
				wagesInfo.put("WeekendOTPaymentRMBCode", weekendOTPaymentRMBCode);
				// WorkdayOTPaymentRMBCode 平日加班费RMB编码
				wagesInfo.put("WorkdayOTPaymentRMBCode", WorkdayOTPaymentRMBCode);
				// PositionAllowanceRMB 岗位津贴RMB金额
				wagesInfo.put("PositionAllowanceRMB", allowanceRMB);
				// PositionAllowanceRMBCode 岗位津贴RMB编码
				wagesInfo.put("PositionAllowanceRMBCode", positionAllowanceRMBCode);
				// HourlyRateRMB 时薪RMB金额
				// wagesInfo.put("HourlyRateRMB", hourlyRateRMB);
				// HourlyRateRMBCode 时薪RMB编码
				wagesInfo.put("HourlyRateRMBCode", hourlyRateRMBCode);
				// ServiceTaxRMBCode 劳务税RMB编码
				wagesInfo.put("ServiceTaxRMBCode", serviceTaxRMBCode);
				// PaymentbeforeRMBCode 税前补款项RMB编码
				wagesInfo.put("PaymentbeforeRMBCode", paymentbeforeRMBCode);
				// GrossWageRMBCode 总时薪RMB编码
				wagesInfo.put("GrossWageRMBCode", grossWageRMBCode);
				// MonthRMBCode 月薪RMB编码
				wagesInfo.put("MonthRMBCode", monthRMBCode);
				// paymentcurrency 支付币种
				wagesInfo.put("paymentcurrency", zfCurrency);
				// insuranceplanCode 年至今社医保公积金编码
				wagesInfo.put("insuranceplanCode", insuranceplannumber);
				// insuranceplan 年至今社医保公积金金额
				wagesInfo.put("insuranceplan", insuranceplan);
				// insuranceplanId 年至今社医保公积金id
				wagesInfo.put("insuranceplanId", insuranceplanId);
				// individualIncomeTax 个人所得税金额
				wagesInfo.put("individualIncomeTax", individualIncomeTax);
				// individualIncomeTaxCode 个人所得税编码
				wagesInfo.put("individualIncomeTaxCode", individualIncomeTaxnumber);
				// individualIncomeTaxId 个人所得税id
				wagesInfo.put("individualIncomeTaxId", individualIncomeTaxId);
				// housingfund 公积金金额
				wagesInfo.put("housingfund", housingfund);
				// housingfundCode 公积金编码
				wagesInfo.put("housingfundCode", housingfundnumber);
				// housingfundId 公积金id
				wagesInfo.put("housingfundId", housingfundId);
				// medicalCode 医保编码
				wagesInfo.put("medicalCode", sedicalinsurancenumber);
				// medicalId 医保id
				wagesInfo.put("medicalId", sedicalinsuranceId);
				// medical 医保金额
				wagesInfo.put("medical", sedicalinsurance);
				// socialinsurance 社保金额
				wagesInfo.put("socialinsurance", socialinsurance);
				// socialinsuranceCode 社保编码
				wagesInfo.put("socialinsuranceCode", socialinsurancenumber);
				// socialinsuranceId 社保id
				wagesInfo.put("socialinsuranceId", socialinsuranceId);
				// subsidyId 高温补贴id
				wagesInfo.put("subsidyId", subsidyId);
				// subsidyCode 高温补贴编码
				wagesInfo.put("subsidyCode", subsidynumber);
				// subsidyamount 高温补贴金额
				wagesInfo.put("subsidyamount", subsidy);
				// weekendOTPaymentId 休息日加班费id
				wagesInfo.put("weekendOTPaymentId", weekendOTPaymentId);
				// weekendOTPaymentCode 休息日加班费编码
				wagesInfo.put("weekendOTPaymentCode", weekendOTPaymentnumber);
				// weekendOTPayment 休息日加班费金额
				wagesInfo.put("weekendOTPayment", weekendOTPayment);
				// workdayOTPaymentCode 平日加班费编码
				wagesInfo.put("workdayOTPaymentCode", workdayOTPaymentnumber);
				// workdayOTPaymentId 平日加班费Id
				wagesInfo.put("workdayOTPaymentId", workdayOTPaymentId);
				// workdayOTPayment 平日加班费
				wagesInfo.put("workdayOTPayment", workdayOTPayment);
				// allowanceCode 岗位津贴编码
				wagesInfo.put("allowanceCode", allowanceIdnumber);
				// allowanceId 岗位津贴id
				wagesInfo.put("allowanceId", allowanceId);
				// allowancecmount 岗位津贴金额
				wagesInfo.put("allowancecmount", allowance);
				// settlementcyle 工资结算周期
				wagesInfo.put("settlementcyle", wagsenglist);
				// Nationalits 国籍(新)
				wagesInfo.put("Nationalits", guoji);
				wagesInfo.put("Nationalits", guoji, LocaleUtils.locale_l2);
				wagesInfo.put("Nationalits", guoji, LocaleUtils.locale_l1);
				// cuueryName 发放币别
				wagesInfo.put("cuueryName", ffPaymentcurrency);
				// currencyId 发放币别id
				wagesInfo.put("currencyId", curreyId);
				// MonthlysalaryCode 月薪编码
				wagesInfo.put("MonthlysalaryCode", monthnumber);
				// GrossWageCode 总时薪编码
				wagesInfo.put("GrossWageCode", grossnumber);
				// PaymentbeforeCode 税前不款项编码
				wagesInfo.put("PaymentbeforeCode", beforeTaxnumber);
				// grossincomeCode 年至今税前总工资金额编码
				wagesInfo.put("grossincomeCode", incomebeforenumber);
				// ServiceTaxCode 劳务税金额编码
				wagesInfo.put("ServiceTaxCode", servicenumber);
				// YTDtaxCode 年至今个人所得税编码
				wagesInfo.put("YTDtaxCode", ytdtaxnumber);
				// netpaymentCode 年至今实发工资金额编码
				wagesInfo.put("netpaymentCode", netpaymentnumber);
				// HourlyRateCode 时薪编码
				wagesInfo.put("HourlyRateCode", hoursnumber);
				// WorkingHoursCode 工作小时数编码
				wagesInfo.put("WorkingHoursCode", workernumber);
				// AttendanceCode 出勤天数编码
				wagesInfo.put("AttendanceCode", attendancenumber);
				// department 部门
				wagesInfo.put("department", bumenName, LocaleUtils.locale_l1);
				wagesInfo.put("department", bumenName, LocaleUtils.locale_l2);
				wagesInfo.put("department", bumenName);
				// peronid 员工id
				wagesInfo.put("peronid", topersonid);
				// Attendancecount 出勤天数数量
				wagesInfo.put("Attendancecount", Attendancedays);
				// WorkingHourscount 工作小时数数量
				wagesInfo.put("WorkingHourscount", workingHours);
				// WorkingHours 工作小时数id
				wagesInfo.put("WorkingHours", workerID);
				// HourlyRateamount 时薪金额
				wagesInfo.put("HourlyRateamount", hourlyRate);
				// HourlyRate 时薪id
				wagesInfo.put("HourlyRate", hoursId);
				// netpaymentamount 年至今实发工资金额
				wagesInfo.put("netpaymentamount", netpayment);
				// YTDnetpayment 年至今实发工资id
				wagesInfo.put("YTDnetpayment", netpaymentId);
				// YTDtaxamount 年至今个人所得税金额
				wagesInfo.put("YTDtaxamount", ytdtax);
				// YTDtax 年至今个人所得税id
				wagesInfo.put("YTDtax", ytdtaxId);
				// grossincome 年至今税前总工资金额
				wagesInfo.put("grossincome", incomebeforetax);
				// ytdgrossincome 年至今税前总工资id
				wagesInfo.put("ytdgrossincome", incomebeforeId);
				// ServiceTaxamount 劳务税金额
				wagesInfo.put("ServiceTaxamount", serviceTax);
				// ServiceTax 劳务税id
				wagesInfo.put("ServiceTax", serviceID);
				// beforeamcount 税前补款项金额
				wagesInfo.put("beforeamcount", paymentbeforeTax);
				// PaymentbeforeTax 税前补款项id
				wagesInfo.put("PaymentbeforeTax", beforeTaxId);
				// grossamount 总时薪金额
				wagesInfo.put("grossamount", grossWage);
				// GrossWage 总时薪id
				wagesInfo.put("GrossWage", grossid);
				// amount 月薪金额
				wagesInfo.put("amount", monthlysalary);
				// Monthlysalary 月薪的id
				wagesInfo.put("Monthlysalary", monthId);
				// Nationali 国籍
				// wagesInfo.put("Nationali", value);
				// Attendancedays 出勤天数id
				wagesInfo.put("Attendancedays", monthId);
				// 身份证/护照号码
				wagesInfo.setIdcardno(idno);
				// //工号
				wagesInfo.setStaffno(personNumber);
				// 姓名
				wagesInfo.setPersonname(personName);
				// 计算规则名称
				wagesInfo.setCalculationName(gzname);
				// 计算规则编码
				wagesInfo.setCalculationNumber(gznumber);
				// 是否锁定
				wagesInfo.setIsitlocked(locke);
				// 结束时间
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				wagesInfo.setEndtime(sdf.parse(endtime));
				// 起始时间tostarttime
				wagesInfo.setStarttime(sdf.parse(tostarttime));
				// 公司名称
				// 统计月
				wagesInfo.setStatisticalmonth(countmonth);
				// 统计年
				wagesInfo.setStatisticalyear(countyear);
				// 核算次数
				wagesInfo.setAccountingfrequency(fCalTime);
				// 核算状态
				wagesInfo.setAccountingstatus(calstatus);

				// 单据状态
				// HR组织
				HROrgUnitInfo hrOrgUnitInfo = HROrgUnitFactory.getLocalInstance(ctx)
						.getHROrgUnitInfo(new ObjectUuidPK(hrID));
				wagesInfo.setHrOrgUnit(hrOrgUnitInfo);
				// 行政组织
				AdminOrgUnitInfo adminOrgUnitInfo = AdminOrgUnitFactory.getLocalInstance(ctx)
						.getAdminOrgUnitInfo(new ObjectUuidPK(drementid));
				wagesInfo.setAdminOrg(adminOrgUnitInfo);
				// 来源功能
				// 原始单据ID
				// 审核人
				// 是否曾经生效
				// 参考信息
				// 经手人
				// 业务日期
				// 单据编号
				String fname = personName + countyear + "年" + countmonth + "月" + "工资单";
				wagesInfo.setNumber(fname);
				// 控制单元
				// 最后修改时间
				Timestamp timestamp = new Timestamp(nowdate.getTime());
				wagesInfo.setLastUpdateTime(timestamp);
				// 最后修改者
				wagesInfo.setLastUpdateUser(currentUserInfo);
				// 创建时间
				wagesInfo.setCreateTime(timestamp);
				// 创建者
				wagesInfo.setCreator(currentUserInfo);
				// 实发工资金额 netPayment
				wagesInfo.put("shifanetPayment", tonetPayments);
				// 实发工资编码
				wagesInfo.put("netPaymentnumber", netPaymentCode);
				// wagesInfo.put(arg0, arg1, LocaleUtils.locale_l1);
				// 新加薪酬项目
				// Note 备注
				wagesInfo.put("tonotes", note);
				// DeductionafterTax 税后扣款项
				wagesInfo.put("DeductionafterTax", deductionafterTax);
				// PaymentafterTax 税后补款项
				wagesInfo.put("PaymentafterTax", paymentafterTax);
				// SalaryAdvance 预支工资还款
				wagesInfo.put("SalaryAdvance", salaryAdvance);
				// UtilityCost 水电气费用
				wagesInfo.put("UtilityCost", utilityCost);
				// Rent 房租
				wagesInfo.put("Rent", rent);
				// GrossSalary 应发工资合计
				wagesInfo.put("GrossSalary", grossSalary);
				// rentorutility 房租或水电费退款
				wagesInfo.put("rentorutility", rentorutility);
				// Utilityfee 房租水电费总计
				wagesInfo.put("Utilityfee", utilityfee);
				// OtherDeduction 其他扣款
				wagesInfo.put("OtherDeduction", otherDeduction);
				// OtherRefund 其他退款
				wagesInfo.put("OtherRefund", otherRefund);
				// UnpaidLeaveDeduction 事假扣款
				wagesInfo.put("UnpaidLeaveDeduction", unpaidLeaveDeduction);
				// UGSubsidyUG 补贴
				wagesInfo.put("UGSubsidyUG", uGSubsidyUG);
				// AdmissionSubsidy 招生津贴
				wagesInfo.put("AdmissionSubsidy", admissionSubsidy);
				// TaxableOtherBenefit 计税其它福利
				wagesInfo.put("TaxableOtherBenefit", taxableOtherBenefit);
				// TaxableCommercial 计税商业保险
				wagesInfo.put("TaxableCommercial", taxableCommercial);
				// TotalDeductionBeforeTax 税前扣款项合计
				wagesInfo.put("TotalDeductionBeforeTax", totalDeductionBeforeTax);
				// DeductionBeforeTax 税前扣款项
				wagesInfo.put("DeductionBeforeTax", deductionBeforeTax);
				// TotalAllowance 津贴总计
				wagesInfo.put("TotalAllowance", totalAllowance);
				// TeachersDayAllowance 教师节慰问金
				wagesInfo.put("TeachersDayAllowance", teachersDayAllowance);
				// TutoringAllowance2 分摊辅导津贴
				wagesInfo.put("TutoringAllowance2", tutoringAllowance);
				// TutoringAllowance 辅导津贴
				wagesInfo.put("TutoringAllowance", tutoringAllowances);
				// GrossWage2 总日薪
				wagesInfo.put("GrossWage2", grossWages);
				// DailyWage 日薪
				wagesInfo.put("DailyWage", dailyWage);
				// leaveallowance 事假补款
				wagesInfo.put("leaveallowance", leaveallowance);
				// severancepay 一次性经济补偿
				wagesInfo.put("severancepay", severancepay);
				// annualleave 年休假补偿费
				wagesInfo.put("annualleave", annualleave);
				// ERHousing 单位公积金
				wagesInfo.put("ERHousing", eRHousing);
				// ERMedicalins 单位综合医保险
				wagesInfo.put("ERMedicalins", eRMedicalins);
				// ERSocialins 单位社保
				wagesInfo.put("ERSocialins", eRSocialins);
				// TotalTax 个税总计
				wagesInfo.put("TotalTax", totalTax);
				// SeveranceTax 经济补偿金税
				wagesInfo.put("SeveranceTax", severanceTax);
				// NonResident 外籍全年一次性所得税
				wagesInfo.put("NonResident", nonResident);
				// BonusTax1 全年一次性所得税
				wagesInfo.put("BonusTax1", bonusTax);
				// AnnualBonus2 年终奖（与当月薪资合并计税）
				wagesInfo.put("AnnualBonus2", annualBonuss);
				// ForeignerAnnual 外籍年终奖（按一次性所得计税
				wagesInfo.put("ForeignerAnnual", foreignerAnnual);
				// AnnualBonus1 年终奖（按全年一次性所得计税）
				wagesInfo.put("AnnualBonus1", annualBonus);
				// Specialexpense 个税专项扣除
				wagesInfo.put("Specialexpense", specialexpense);
				// TaxableItem 计税不计薪
				wagesInfo.put("TaxableItem", taxableItem);
				// PensionAllowance 养老金补贴
				wagesInfo.put("PensionAllowance", pensionAllowance);
				// HouseAllowance 住房补贴
				wagesInfo.put("HouseAllowance", houseAllowance);
				// CommunicationAllowance 通讯补贴
				wagesInfo.put("CommunicationAllowance", communicationAllowance);
				// OTPayment 总加班费
				wagesInfo.put("OTPayment", oTPayment);
				// HolidayOTPayment 法定假加班费
				wagesInfo.put("HolidayOTPayment", holidayOTPayment);
				// TaxExemption 是否免税
				wagesInfo.put("TaxExemption", taxExemption);
				// 个税专项扣除RMB deductionsfortaxRMB
				// wagesInfo.put("deductionsfortaxRMB", deductionsfortaxRMB);
				// 个税专项扣除deductionsfortax
				wagesInfo.put("deductionsfortax", deductionsfortax);
				// 薪酬核算表的最后修改时间
				String formatTime = tosdf.format(flastupdatetime);
				wagesInfo.put("lasttime", formatTime);

				// 存储新建的薪酬项目的值payVlueMap
				for (Map.Entry<String, String> paymateEntry : payVlueMap.entrySet()) {
					String key = paymateEntry.getKey();
					String value = paymateEntry.getValue();
//					System.out.println("key是" + key + "vlaue是" + value);
					wagesInfo.put(key, value);
				}
				collection.add(wagesInfo);
			}
			WagesChromatographyFactory.getLocalInstance(ctx).addnewBatchData(collection);
			logger.error("保存成功");
			// WagesChromatographyFactory.getLocalInstance(ctx).addnew(collection);
		} catch (SQLException | EASBizException | BOSException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 查询工资单薪酬项目新增里面的数据 map存储薪酬编码 key工资单薪酬项目存储实体类
	 */
	public void getPaydata() {
		// Map<String,PayAddInfo> payMap=new HashMap<>();
		// 查询工资单薪酬项目新增数据表的sql
		String sql = "select * from CT_CUS_AddSalaryproject";
		try {
			IRowSet rs = DbUtil.executeQuery(this.ctx, sql);
			while (rs.next()) {
				PayAddInfo payInfo = new PayAddInfo();
				payInfo.setDepidentifying(rs.getString("cfdepidentifying"));
				payInfo.setPayCode(rs.getString("cfpayCode"));
				payInfo.setIsitcharacter(rs.getString("cfischarct"));
				payMap.put(rs.getString("cfpayCode"), payInfo);
			}
		} catch (BOSException | SQLException e) {
			e.printStackTrace();
		}

	}

	/**
	 * 通过工资单薪酬新增单据添加的薪酬项目 查出这些项目的字段序号 mapkey是薪酬项目编码 value是薪酬项目序号
	 */
	public void getSerial() {
		StringBuffer paySql = new StringBuffer();
		if (!payMap.isEmpty()) {
			paySql.append("SELECT * FROM T_HR_SCmpItem where FNumber in (");
			for (Map.Entry<String, PayAddInfo> entry : payMap.entrySet()) {
				String key = entry.getKey();

				paySql.append("'" + key + "',");

			}
			// 删除最后一个逗号
			paySql.deleteCharAt(paySql.length() - 1);
			paySql.append(")");

		}
		logger.error("通过添加的薪酬项目查询的字段序号的sql是" + paySql.toString());

		try {
			IRowSet rs = DbUtil.executeQuery(this.ctx, paySql.toString());
			while (rs.next()) {
				serialMap.put(rs.getString("FNumber"), "s" + rs.getString("FieldSn"));
			}
		} catch (BOSException | SQLException e) {
			e.printStackTrace();
		}

	}

	/**
	 * 处理薪酬项目字段序号和dep字段标识的对应关系 map key是字段序号 value 工资单新增薪酬项目的实体
	 */
	public Map<String, PayAddInfo> getPaymate() {
		Map<String, PayAddInfo> mateMap = new HashMap<>();
		for (Map.Entry<String, PayAddInfo> entry : payMap.entrySet()) {
			String paydatekey = entry.getKey();
			PayAddInfo payaddInfo = entry.getValue();
			for (Map.Entry<String, String> serialEntry : serialMap.entrySet()) {
				String serialkey = serialEntry.getKey();
				// 字段序号
				String seriaValue = serialEntry.getValue();
				if (paydatekey.equals(serialkey)) {
					mateMap.put(seriaValue, payaddInfo);
					break;
				}
			}
		}
		return mateMap;
	}

	/***
	 * 获取薪酬项目的值 map 可以是字段标识 value是薪酬项目值
	 *
	 */
	public Map<String, String> getPayVlue(IRowSet rs) {
		Map<String, String> payVlueMap = new HashMap<>();
		Map<String, PayAddInfo> paymateMap = getPaymate();
		try {
			for (Map.Entry<String, PayAddInfo> paymateEntry : paymateMap.entrySet()) {
				// 字段序号
				String key = paymateEntry.getKey();
				PayAddInfo payAddInfo = paymateEntry.getValue();
				// dep标识
				String depidentifying = payAddInfo.getDepidentifying();
				String isitcharacter = payAddInfo.getIsitcharacter();
				// 判断是字符还是数值类型 1 字符 2 是数值
				if ("1".equals(isitcharacter)) {
					// 状态
					String charVlue = rs.getString(key) == null ? "" : rs.getString(depidentifying);
					payVlueMap.put(depidentifying, charVlue);
				} else if ("2".equals(isitcharacter)) {
					BigDecimal bigpayVlue = new BigDecimal("0.00");
					if (StringUtils.isNotBlank(rs.getString(key))) {
						bigpayVlue = rs.getBigDecimal(key).setScale(2, RoundingMode.HALF_UP);
						String payVlue = bigpayVlue.toString();
						payVlueMap.put(depidentifying, payVlue);
					}
				}
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return payVlueMap;
	}

	/***
	 * 界面过滤处理
	 */

	public void getFilter(String fastFilterItems, EntityViewInfo defaultViewInfo, String personid,
			UserInfo currentUserInfo, Date nowdate) throws JSONException {
		// 获取过虑条件
		JSONObject tofastFilterItems = new JSONObject(fastFilterItems);
		// 获取过滤的日期
		JSONObject countDateJson = tofastFilterItems.getJSONObject("countDate");
		String year = null;
		String month = null;
		// 获取过滤条件人员
		JSONObject entrysPerson = tofastFilterItems.getJSONObject("entrys.person");
		JSONArray dataItemArray = entrysPerson.getJSONArray("dataItem");
		// 获取编号放入list
		List<String> numberList = new ArrayList<>();
		for (int i = 0; i < dataItemArray.length(); i++) {
			JSONObject data = dataItemArray.getJSONObject(i);
			String number = data.getString("number");
			numberList.add(number);
		}
		// 将list转换成逗号分隔的字符串
		String stringList = String.join(",", numberList);
		FilterInfo tofilterInfo = new FilterInfo();
		if (StringUtils.isNotBlank(stringList)) {
			// 过滤人员编码
			tofilterInfo.getFilterItems().add(new FilterItemInfo("staffno", stringList, CompareType.INNER));
		}
		String values = countDateJson.getString("values");
		if (StringUtils.isNotBlank(values)) {
			JSONObject vluesJson = countDateJson.getJSONObject("values");
			if (values != null) {
				String countDate = vluesJson.getString("date");
				// 处理传过来的日期 只取年月
				year = countDate.substring(0, 4);
				// 截取月
				String tomonthDate = countDate.substring(5, 7);
				// 如果月份是0几月的只取后面的月份
				if (("0").equals(tomonthDate.substring(0, 1))) {
					month = tomonthDate.substring(1, 2);
				} else {
					month = tomonthDate;
				}
				// 过滤统计年月
				tofilterInfo.getFilterItems().add(new FilterItemInfo("statisticalyear", year, CompareType.EQUALS));
				tofilterInfo.getFilterItems().add(new FilterItemInfo("statisticalmonth", month, CompareType.EQUALS));
			}
		}
         // 过滤计算规则编码gt003
		tofilterInfo.getFilterItems().add(new FilterItemInfo("calculationNumber", "GT003", CompareType.NOTEQUALS));
		defaultViewInfo.setFilter(tofilterInfo);
	}

	/***
	 * 获取动态新增薪酬项目的数量 判断薪酬项目有没有新增
	 *
	 * @return
	 */
	public String countFiled() {
		String sql = "select count(*)as count from CT_CUS_AddSalaryproject";
		String countFiled = null;
		try {
			IRowSet rs = DbUtil.executeQuery(this.ctx, sql);
			while (rs.next()) {
				countFiled = rs.getString("count");
			}
		} catch (BOSException | SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return countFiled;
	}

	/***
	 * 修改数据库统计薪酬字段数量的字段
	 *
	 * @param countFiled
	 */
	public void updateFiled(String countFiled) {

		// 获取新增字段的数量
		List<String> filedList = countFiledMap.get("CFAddFiled");
		// 判断薪酬项目的数量的值是否在list里面 不在就要修改数据
		if (!filedList.contains(countFiled)) {
			String updateSql = "UPDATE CT_SAL_WagesChromatography SET CFAddFiled =" + "'" + countFiled + "'";
			System.out.print("添加薪酬项目统计数的修改语句"+updateSql);
			try {
				DbUtil.execute(ctx, updateSql);
			} catch (BOSException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}
		}
	}



	/***
	 *
	 * 查询homepage薪酬基础数据/薪酬预留基础数据0下面的数据
	 * 编码为1006的; 数据有没有修改; 修改则更新工资条数据;
	 * coyle20250430
	 * @return
	 */
	public boolean checkDayisUp() {
		boolean isUp = false;
		String dateFormat = DateTimeUtils.dateFormat(new Date(), "yyyy-MM-dd");
		String sql = "select * from T_HR_SHRRsvItem0 where fnumber = '1006'  " +
				"and  flastupdatetime  >= {" + dateFormat + "} ";
		try {
			IRowSet rs = DbUtil.executeQuery(this.ctx, sql);
			while (rs.next()) {
				isUp = true;
			}
		} catch (SQLException | BOSException e) {
			e.printStackTrace();
		}
		return isUp;
	}


	/***
	 * 修改数据库薪酬基础数据/薪酬预留基础数据0下面编码为1006的的数据
	 * 20250430
	 * coyle
	 */
	public void upDayDataDate() {
		//该最后修改时间为昨天的; 这个时间上面用做了判断条件,为了使其不再更新工资包的数;
		Date update = com.kingdee.util.DateTimeUtils.addDay(new Date(), -1) ;
		String formatDate = tosdf.format(update);
		String updateSql = "UPDATE T_HR_SHRRsvItem0 SET flastupdatetime = ? where fnumber = '1006' ";
		System.out.print("修改薪酬基础数据/薪酬预留基础数据0下面编码为1006的的数据的修改语句"+updateSql);
		try {
			DbUtil.execute(ctx, updateSql,new Object[] {formatDate});
		} catch (BOSException e) {
			e.printStackTrace();
		}
	}



	/***
	 * 只应对导入历史数据的特殊场景
	 * 查询homepage 薪酬基础数据/薪酬预留基础数据0下面的数据
	 * 编码为1008的; 工资条生成哪一年的数据;如需要重新生成2021年,则填入2021年; 如果是0;则表示为今年的数据; 默认为"0";需导入历史数据时,更新此参数; 请勿填入其他特殊参数;
	 * coyle20250516
	 * @return
	 */
	public  void   setYearParam() {
		// 获取当前年份
		currentYear = DateTimeUtils.dateFormat(new Date(), "yyyy");
		String sql = "select fname_l2 from T_HR_SHRRsvItem0 where fnumber = '1008'  " ;
		try {
			IRowSet rs = DbUtil.executeQuery(this.ctx, sql);
			while (rs.next()) {
				String yearStr = rs.getString("fname_l2");
				//如果为0或者不为数字,则不处理
				if(StringUtils.isNotBlank(yearStr) && !StringUtils.equals("0",yearStr) && StringUtils.isNumeric(yearStr)) {
					currentYear = yearStr;
				}
			}
			logger.error("当前年份为:"+currentYear);
//			System.out.println("当前年份为:"+currentYear);
		} catch (SQLException | BOSException e) {
			e.printStackTrace();
		}
	}

}
