<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, lengleng All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the yifu4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: lengleng (wangiegie@gmail.com)
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialFundInfoMapper">

	<resultMap id="tSocialFundInfoMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFundInfo">
		<id property="id" column="ID"/>
		<result property="empId" column="EMP_ID"/>
		<result property="empNo" column="EMP_NO"/>
		<result property="empName" column="EMP_NAME"/>
		<result property="empIdcard" column="EMP_IDCARD"/>
		<result property="empType" column="EMP_TYPE"/>
		<result property="settleDomain" column="SETTLE_DOMAIN"/>
		<result property="settleDomainCode" column="SETTLE_DOMAIN_CODE"/>
		<result property="settleDomainName" column="SETTLE_DOMAIN_NAME"/>
		<result property="unitName" column="UNIT_NAME"/>
		<result property="unitId" column="UNIT_ID"/>

		<result property="settleDomainFund" column="SETTLE_DOMAIN_FUND"/>
		<result property="settleDomainCodeFund" column="SETTLE_DOMAIN_CODE_FUND"/>
		<result property="settleDomainNameFund" column="SETTLE_DOMAIN_NAME_FUND"/>
		<result property="unitNameFund" column="UNIT_NAME_FUND"/>
		<result property="unitIdFund" column="UNIT_ID_FUND"/>

		<result property="socialHousehold" column="SOCIAL_HOUSEHOLD"/>
		<result property="socialHouseholdName" column="SOCIAL_HOUSEHOLD_NAME"/>
		<result property="socialProvince" column="SOCIAL_PROVINCE"/>
		<result property="socialCity" column="SOCIAL_CITY"/>
		<result property="socialTown" column="SOCIAL_TOWN"/>
		<result property="providentHousehold" column="PROVIDENT_HOUSEHOLD"/>
		<result property="providentHouseholdName" column="PROVIDENT_HOUSEHOLD_NAME"/>
		<result property="fundProvince" column="FUND_PROVINCE"/>
		<result property="fundCity" column="FUND_CITY"/>
		<result property="fundTown" column="FUND_TOWN"/>
		<result property="socialAddStatus" column="SOCIAL_ADD_STATUS"/>
		<result property="fundAddStatus" column="FUND_ADD_STATUS"/>
		<result property="socialReduceStatus" column="SOCIAL_REDUCE_STATUS"/>
		<result property="fundReduceStatus" column="FUND_REDUCE_STATUS"/>
		<result property="socialId" column="SOCIAL_ID"/>
		<result property="fundId" column="FUND_ID"/>
		<result property="createBy" column="CREATE_BY"/>
		<result property="updateBy" column="UPDATE_BY"/>
		<result property="createName" column="CREATE_NAME"/>
		<result property="createTime" column="CREATE_TIME"/>
		<result property="updateTime" column="UPDATE_TIME"/>
		<result property="firstBuyMonthSocial" column="FIRST_BUY_MONTH_SOCIAL"/>
		<result property="unitPensionCardinal" column="UNIT_PENSION_CARDINAL"/>
		<result property="unitMedicalCardinal" column="UNIT_MEDICAL_CARDINAL"/>
		<result property="unitUnemploymentCardinal" column="UNIT_UNEMPLOYMENT_CARDINAL"/>
		<result property="unitBigailmentCardinal" column="UNIT_BIGAILMENT_CARDINAL"/>
		<result property="unitWorkInjuryCardinal" column="UNIT_WORK_INJURY_CARDINAL"/>
		<result property="unitBirthCardinal" column="UNIT_BIRTH_CARDINAL"/>
		<result property="personalPensionCardinal" column="PERSONAL_PENSION_CARDINAL"/>
		<result property="personalMedicalCardinal" column="PERSONAL_MEDICAL_CARDINAL"/>
		<result property="personalBigailmentCardinal" column="PERSONAL_BIGAILMENT_CARDINAL"/>
		<result property="personalUnemploymentCardinal" column="PERSONAL_UNEMPLOYMENT_CARDINAL"/>
		<result property="unitPensionPer" column="UNIT_PENSION_PER"/>
		<result property="unitMedicalPer" column="UNIT_MEDICAL_PER"/>
		<result property="unitUnemploymentPer" column="UNIT_UNEMPLOYMENT_PER"/>
		<result property="unitWorkUnjuryPer" column="UNIT_WORK_UNJURY_PER"/>
		<result property="unitBirthPer" column="UNIT_BIRTH_PER"/>
		<result property="personalPensionPer" column="PERSONAL_PENSION_PER"/>
		<result property="personalMedicalPer" column="PERSONAL_MEDICAL_PER"/>
		<result property="personalUnemploymentPer" column="PERSONAL_UNEMPLOYMENT_PER"/>
		<result property="handleStatus" column="HANDLE_STATUS"/>
		<result property="personalBigailmentPer" column="PERSONAL_BIGAILMENT_PER"/>
		<result property="unitBigailmentPer" column="UNIT_BIGAILMENT_PER"/>
		<result property="socialReduceDate" column="SOCIAL_REDUCE_DATE"/>
		<result property="canOverpay" column="CAN_OVERPAY"/>
		<result property="payPolicy" column="PAY_POLICY"/>
		<result property="overpayNumber" column="OVERPAY_NUMBER"/>
		<result property="haveThisMonth" column="HAVE_THIS_MONTH"/>
		<result property="insurancePension" column="INSURANCE_PENSION"/>
		<result property="insuranceMedical" column="INSURANCE_MEDICAL"/>
		<result property="insuranceUnemployment" column="INSURANCE_UNEMPLOYMENT"/>
		<result property="insuranceInjury" column="INSURANCE_INJURY"/>
		<result property="insuranceBirth" column="INSURANCE_BIRTH"/>
		<result property="insuranceBigailment" column="INSURANCE_BIGAILMENT"/>
		<result property="latestCardinality" column="LATEST_CARDINALITY"/>
		<result property="isIllness" column="IS_ILLNESS"/>
		<result property="collectType" column="COLLECT_TYPE"/>
		<result property="valueType" column="VALUE_TYPE"/>
		<result property="collectMoth" column="COLLECT_MOTH"/>
		<result property="isChargePersonal" column="IS_CHARGE_PERSONAL"/>
		<result property="recordBase" column="RECORD_BASE"/>
		<result property="trustRemark" column="TRUST_REMARK"/>
		<result property="paymentType" column="PAYMENT_TYPE"/>
		<result property="upperLimit" column="UPPER_LIMIT"/>
		<result property="lowerLimit" column="LOWER_LIMIT"/>
		<result property="pensionStart" column="PENSION_START"/>
		<result property="medicalStart" column="MEDICAL_START"/>
		<result property="unemployStart" column="UNEMPLOY_START"/>
		<result property="workInjuryStart" column="WORK_INJURY_START"/>
		<result property="birthStart" column="BIRTH_START"/>
		<result property="bigailmentStart" column="BIGAILMENT_START"/>

		<result property="pensionReduceStart" column="PENSION_REDUCE_START"/>
		<result property="medicalReduceStart" column="MEDICAL_REDUCE_START"/>
		<result property="unemployReduceStart" column="UNEMPLOY_REDUCE_START"/>
		<result property="workInjuryReduceStart" column="WORK_INJURY_REDUCE_START"/>
		<result property="birthReduceStart" column="BIRTH_REDUCE_START"/>
		<result property="bigailmentReduceStart" column="BIGAILMENT_REDUCE_START"/>

		<result property="pensionHandle" column="PENSION_HANDLE"/>
		<result property="medicalHandle" column="MEDICAL_HANDLE"/>
		<result property="unemployHandle" column="UNEMPLOY_HANDLE"/>
		<result property="workInjuryHandle" column="WORK_INJURY_HANDLE"/>
		<result property="birthHandle" column="BIRTH_HANDLE"/>
		<result property="bigailmentHandle" column="BIGAILMENT_HANDLE"/>
		<result property="unitPersionMoney" column="UNIT_PERSION_MONEY"/>
		<result property="unitMedicalMoney" column="UNIT_MEDICAL_MONEY"/>
		<result property="unitUnemploymentMoney" column="UNIT_UNEMPLOYMENT_MONEY"/>
		<result property="unitInjuryMoney" column="UNIT_INJURY_MONEY"/>
		<result property="unitBirthMoney" column="UNIT_BIRTH_MONEY"/>
		<result property="unitBigailmentMoney" column="UNIT_BIGAILMENT_MONEY"/>
		<result property="personalPersionMoney" column="PERSONAL_PERSION_MONEY"/>
		<result property="personalMedicalMoney" column="PERSONAL_MEDICAL_MONEY"/>
		<result property="personalUnemploymentMoney" column="PERSONAL_UNEMPLOYMENT_MONEY"/>
		<result property="personalBigailmentMoney" column="PERSONAL_BIGAILMENT_MONEY"/>
		<result property="unitProvidengCardinal" column="UNIT_PROVIDENG_CARDINAL"/>
		<result property="personalProvidentCardinal" column="PERSONAL_PROVIDENT_CARDINAL"/>
		<result property="socialStartDate" column="SOCIAL_START_DATE"/>
		<result property="unitProvidentPer" column="UNIT_PROVIDENT_PER"/>
		<result property="personalProvidentPer" column="PERSONAL_PROVIDENT_PER"/>
		<result property="providentStart" column="PROVIDENT_START"/>
		<result property="firstBuyMothFund" column="FIRST_BUY_MOTH_FUND"/>
		<result property="upperLimitFund" column="UPPER_LIMIT_FUND"/>
		<result property="lowerLimitFund" column="LOWER_LIMIT_FUND"/>
		<result property="fundPayPoint" column="FUND_PAY_POINT"/>
		<result property="canOverpayFund" column="CAN_OVERPAY_FUND"/>
		<result property="overpayNumberFund" column="OVERPAY_NUMBER_FUND"/>
		<result property="payPolicyFund" column="PAY_POLICY_FUND"/>
		<result property="trustRemarkFund" column="TRUST_REMARK_FUND"/>
		<result property="haveThisMonthFund" column="HAVE_THIS_MONTH_FUND"/>
		<result property="latestCardinalityFund" column="LATEST_CARDINALITY_FUND"/>
		<result property="fundReduceDate" column="FUND_REDUCE_DATE"/>

		<result property="personalFundSum" column="PERSONAL_FUND_SUM"/>
		<result property="unitFundSum" column="UNIT_FUND_SUM"/>
		<result property="unitSocialSum" column="UNIT_SOCIAL_SUM"/>
		<result property="personalSocialSum" column="PERSONAL_SOCIAL_SUM"/>
		<result property="unitInterestFee" column="UNIT_INTEREST_FEE"/>
		<result property="personalInterestFee" column="PERSONAL_INTEREST_FEE"/>
		<result property="socialStatus" column="SOCIAL_STATUS"/>
		<result property="fundStatus" column="FUND_STATUS"/>
		<result property="dispatchId" column="DISPATCH_ID"/>
		<result property="socialIdSuccess" column="SOCIAL_ID_SUCCESS"/>

	</resultMap>

	<!-- 社保公积金查询的导出专用 -->
	<resultMap id="exportMap" type="com.yifu.cloud.plus.v1.yifu.social.vo.TSocialFundInfoExportVo">
		<id property="id" column="ID"/>
		<result property="empName" column="EMP_NAME"/>
		<result property="empIdcard" column="EMP_IDCARD"/>
		<result property="empType" column="EMP_TYPE"/>
		<result property="empMobile" column="EMP_MOBILE"/>
		<result property="settleDomainCode" column="SETTLE_DOMAIN_CODE"/>
		<result property="unitName" column="UNIT_NAME"/>
		<result property="settleDomainName" column="SETTLE_DOMAIN_NAME"/>
		<result property="idCardProvince" column="ID_CARD_PROVINCE"/>
		<result property="idCardCity" column="ID_CARD_CITY"/>
		<result property="idCardTown" column="ID_CARD_TOWN"/>
		<result property="idCardAddress" column="ID_CARD_ADDRESS"/>
		<result property="fileProvince" column="FILE_PROVINCE"/>
		<result property="fileCity" column="FILE_CITY"/>
		<result property="fileTown" column="FILE_TOWN"/>
		<result property="post" column="POST"/>
		<result property="tryPeriod" column="TRY_PERIOD"/>
		<result property="workingHours" column="WORKING_HOURS"/>
		<result property="contractName" column="CONTRACT_NAME"/>
		<result property="contractSubName" column="CONTRACT_SUB_NAME"/>
		<result property="contractParty" column="CONTRACT_PARTY"/>
		<result property="contractType" column="CONTRACT_TYPE"/>
		<result property="contractStart" column="CONTRACT_START"/>
		<result property="contractEnd" column="CONTRACT_END"/>
		<result property="contractTerm" column="CONTRACT_TERM"/>
		<result property="educationName" column="EDUCATION_NAME"/>
		<result property="recordBase" column="RECORD_BASE"/>
		<result property="socialStatus" column="SOCIAL_STATUS"/>
		<result property="fundStatus" column="FUND_STATUS"/>
		<result property="socialStartDate" column="SOCIAL_START_DATE"/>
		<result property="providentStart" column="PROVIDENT_START"/>
		<result property="socialReduceDate" column="SOCIAL_REDUCE_DATE"/>
		<result property="fundReduceDate" column="FUND_REDUCE_DATE"/>
		<result property="unitSocialSum" column="UNIT_SOCIAL_SUM"/>
		<result property="personalSocialSum" column="PERSONAL_SOCIAL_SUM"/>
		<result property="unitFundSum" column="UNIT_FUND_SUM"/>
		<result property="personalFundSum" column="PERSONAL_FUND_SUM"/>
		<result property="allSum" column="ALL_SUM"/>
		<result property="socialHouseholdName" column="SOCIAL_HOUSEHOLD_NAME"/>
		<result property="socialProvince" column="SOCIAL_PROVINCE"/>
		<result property="socialCity" column="SOCIAL_CITY"/>
		<result property="socialTown" column="SOCIAL_TOWN"/>
		<result property="pensionStart" column="PENSION_START"/>
		<result property="medicalStart" column="MEDICAL_START"/>
		<result property="unemployStart" column="UNEMPLOY_START"/>
		<result property="workInjuryStart" column="WORK_INJURY_START"/>
		<result property="birthStart" column="BIRTH_START"/>
		<result property="bigailmentStart" column="BIGAILMENT_START"/>
		<result property="paymentType" column="PAYMENT_TYPE"/>

		<result property="unitPensionCardinal" column="UNIT_PENSION_CARDINAL"/>
		<result property="unitMedicalCardinal" column="UNIT_MEDICAL_CARDINAL"/>
		<result property="unitUnemploymentCardinal" column="UNIT_UNEMPLOYMENT_CARDINAL"/>
		<result property="unitWorkInjuryCardinal" column="UNIT_WORK_INJURY_CARDINAL"/>
		<result property="unitBirthCardinal" column="UNIT_BIRTH_CARDINAL"/>
		<result property="unitBigailmentCardinal" column="UNIT_BIGAILMENT_CARDINAL"/>
		<result property="unitPensionPer" column="UNIT_PENSION_PER"/>
		<result property="unitMedicalPer" column="UNIT_MEDICAL_PER"/>
		<result property="unitUnemploymentPer" column="UNIT_UNEMPLOYMENT_PER"/>
		<result property="unitWorkUnjuryPer" column="UNIT_WORK_UNJURY_PER"/>
		<result property="unitBirthPer" column="UNIT_BIRTH_PER"/>
		<result property="unitBigailmentPer" column="UNIT_BIGAILMENT_PER"/>
		<result property="unitPersionMoney" column="UNIT_PERSION_MONEY"/>
		<result property="unitMedicalMoney" column="UNIT_MEDICAL_MONEY"/>
		<result property="unitUnemploymentMoney" column="UNIT_UNEMPLOYMENT_MONEY"/>
		<result property="unitInjuryMoney" column="UNIT_INJURY_MONEY"/>
		<result property="unitBirthMoney" column="UNIT_BIRTH_MONEY"/>
		<result property="unitBigailmentMoney" column="UNIT_BIGAILMENT_MONEY"/>

		<result property="personalPensionPer" column="PERSONAL_PENSION_PER"/>
		<result property="personalMedicalPer" column="PERSONAL_MEDICAL_PER"/>
		<result property="personalUnemploymentPer" column="PERSONAL_UNEMPLOYMENT_PER"/>
		<result property="personalBigailmentPer" column="PERSONAL_BIGAILMENT_PER"/>
		<result property="personalPersionMoney" column="PERSONAL_PERSION_MONEY"/>
		<result property="personalMedicalMoney" column="PERSONAL_MEDICAL_MONEY"/>
		<result property="personalUnemploymentMoney" column="PERSONAL_UNEMPLOYMENT_MONEY"/>
		<result property="personalBigailmentMoney" column="PERSONAL_BIGAILMENT_MONEY"/>

		<result property="persionMoney" column="PERSION_MONEY"/>
		<result property="medicalMoney" column="MEDICAL_MONEY"/>
		<result property="unemploymentMoney" column="UNEMPLOYMENT_MONEY"/>
		<result property="bigailmentMoney" column="BIGAILMENT_MONEY"/>

		<result property="providentHouseholdName" column="PROVIDENT_HOUSEHOLD_NAME"/>
		<result property="fundProvince" column="FUND_PROVINCE"/>
		<result property="fundCity" column="FUND_CITY"/>
		<result property="fundTown" column="FUND_TOWN"/>
		<result property="unitProvidengCardinal" column="UNIT_PROVIDENG_CARDINAL"/>
		<result property="unitProvidentPer" column="UNIT_PROVIDENT_PER"/>
		<result property="personalProvidentPer" column="PERSONAL_PROVIDENT_PER"/>
		<result property="unitFundSum2" column="UNIT_FUND_SUM2"/>
		<result property="personalFundSum2" column="PERSONAL_FUND_SUM2"/>
		<result property="fundSum" column="FUND_SUM"/>

		<result property="trustRemark" column="TRUST_REMARK"/>
		<result property="empNational" column="EMP_NATIONAL"/>
		<result property="empRegisType" column="EMP_REGIS_TYPE"/>

	</resultMap>

	<resultMap id="unSocialFundInfoMap" type="com.yifu.cloud.plus.v1.yifu.social.vo.UnSocialFundInfoVo">
		<result property="id" column="ID"/>
		<result property="socialHouseholdName" column="SOCIAL_HOUSEHOLD_NAME"/>
		<result property="paymentType" column="PAYMENT_TYPE"/>
		<result property="socialStatus" column="SOCIAL_STATUS"/>
		<result property="deptNo" column="SETTLE_DOMAIN_CODE"/>
		<result property="deptName" column="SETTLE_DOMAIN_NAME"/>
		<result property="dispatchName" column="dispatchName"/>
		<result property="dispatchTime" column="dispatchTime"/>
		<result property="socialProvince" column="SOCIAL_PROVINCE"/>
		<result property="socialCity" column="SOCIAL_CITY"/>
		<result property="socialTown" column="SOCIAL_TOWN"/>
		<result property="pensionStart" column="PENSION_START"/>
		<result property="medicalStart" column="MEDICAL_START"/>
		<result property="unemployStart" column="UNEMPLOY_START"/>
		<result property="workInjuryStart" column="WORK_INJURY_START"/>
		<result property="birthStart" column="BIRTH_START"/>
		<result property="bigailmentStart" column="BIGAILMENT_START"/>
		<result property="recordBase" column="RECORD_BASE"/>
		<result property="trustRemark" column="TRUST_REMARK"/>
	</resultMap>

	<resultMap id="unFundInfoMap" type="com.yifu.cloud.plus.v1.yifu.social.vo.UnFundInfoVo">
		<result property="id" column="ID"/>
		<result property="fundHouseholdName" column="PROVIDENT_HOUSEHOLD_NAME"/>
		<result property="paymentType" column="PAYMENT_TYPE"/>
		<result property="fundStatus" column="FUND_STATUS"/>
		<result property="deptNo" column="SETTLE_DOMAIN_CODE_FUND"/>
		<result property="deptName" column="SETTLE_DOMAIN_NAME_FUND"/>
		<result property="dispatchName" column="dispatchName"/>
		<result property="dispatchTime" column="dispatchTime"/>
		<result property="fundProvince" column="FUND_PROVINCE"/>
		<result property="fundCity" column="FUND_CITY"/>
		<result property="fundTown" column="FUND_TOWN"/>
		<result property="unitProvidentPer" column="UNIT_PROVIDENT_PER"/>
		<result property="personalProvidentPer" column="PERSONAL_PROVIDENT_PER"/>
		<result property="providentCardinal" column="UNIT_PROVIDENG_CARDINAL"/>
		<result property="providentStart" column="PROVIDENT_START"/>
	</resultMap>

	<sql id="Base_Column_List">
				a.ID,
                a.EMP_ID,
                a.EMP_NO,
                a.EMP_NAME,
                a.EMP_IDCARD,
                a.EMP_TYPE,
                a.SETTLE_DOMAIN,
                if(a.SETTLE_DOMAIN_CODE = a.SETTLE_DOMAIN_CODE_FUND,a.SETTLE_DOMAIN_CODE,concat(ifnull(a.SETTLE_DOMAIN_CODE,""),if((a.SETTLE_DOMAIN_CODE is not null and a.SETTLE_DOMAIN_CODE !='') and (a.SETTLE_DOMAIN_CODE_FUND is not null and a.SETTLE_DOMAIN_CODE_FUND !=''),",",""),ifnull(a.SETTLE_DOMAIN_CODE_FUND,""))) SETTLE_DOMAIN_CODE,
				if(a.SETTLE_DOMAIN_NAME = a.SETTLE_DOMAIN_NAME_FUND,a.SETTLE_DOMAIN_NAME,concat(ifnull(a.SETTLE_DOMAIN_NAME,""),if((a.SETTLE_DOMAIN_NAME is not null and a.SETTLE_DOMAIN_NAME !='') and (a.SETTLE_DOMAIN_NAME_FUND is not null and a.SETTLE_DOMAIN_NAME_FUND !=''),",",""),ifnull(a.SETTLE_DOMAIN_NAME_FUND,""))) SETTLE_DOMAIN_NAME,
				if(a.UNIT_NAME = a.UNIT_NAME_FUND,a.UNIT_NAME,concat(ifnull(a.UNIT_NAME,""),if((a.UNIT_NAME is not null and a.UNIT_NAME !='') and (a.UNIT_NAME_FUND is not null and a.UNIT_NAME_FUND !=''),",",""),ifnull(a.UNIT_NAME_FUND,""))) UNIT_NAME,
                a.UNIT_ID,
 				a.SETTLE_DOMAIN_FUND,
				a.SETTLE_DOMAIN_CODE_FUND,
                a.SETTLE_DOMAIN_NAME_FUND,
                a.UNIT_NAME_FUND,
                a.UNIT_ID_FUND,
                a.SOCIAL_HOUSEHOLD,
                a.SOCIAL_HOUSEHOLD_NAME,
                a.SOCIAL_PROVINCE,
                a.SOCIAL_CITY,
                a.SOCIAL_TOWN,
                a.PROVIDENT_HOUSEHOLD,
                a.PROVIDENT_HOUSEHOLD_NAME,
                a.FUND_PROVINCE,
                a.FUND_CITY,
                a.FUND_TOWN,
                a.SOCIAL_ADD_STATUS,
                a.FUND_ADD_STATUS,
                a.SOCIAL_REDUCE_STATUS,
                a.FUND_REDUCE_STATUS,
                a.SOCIAL_ID,
                a.FUND_ID,
                a.CREATE_BY,
                a.UPDATE_BY,
                a.CREATE_NAME,
                a.UPDATE_TIME,
                a.CREATE_TIME,
                a.FIRST_BUY_MONTH_SOCIAL,
                a.UNIT_PENSION_CARDINAL,
                a.UNIT_MEDICAL_CARDINAL,
                a.UNIT_UNEMPLOYMENT_CARDINAL,
                a.UNIT_BIGAILMENT_CARDINAL,
                a.UNIT_WORK_INJURY_CARDINAL,
                a.UNIT_BIRTH_CARDINAL,
                a.PERSONAL_PENSION_CARDINAL,
                a.PERSONAL_MEDICAL_CARDINAL,
                a.PERSONAL_BIGAILMENT_CARDINAL,
                a.PERSONAL_UNEMPLOYMENT_CARDINAL,
                a.UNIT_PENSION_PER,
                a.UNIT_MEDICAL_PER,
                a.UNIT_UNEMPLOYMENT_PER,
                a.UNIT_WORK_UNJURY_PER,
                a.UNIT_BIRTH_PER,
                a.PERSONAL_PENSION_PER,
                a.PERSONAL_MEDICAL_PER,
                a.PERSONAL_UNEMPLOYMENT_PER,
                a.HANDLE_STATUS,
                a.PERSONAL_BIGAILMENT_PER,
                a.UNIT_BIGAILMENT_PER,
                a.SOCIAL_REDUCE_DATE,
                a.CAN_OVERPAY,
                a.PAY_POLICY,
                a.OVERPAY_NUMBER,
                a.HAVE_THIS_MONTH,
                a.INSURANCE_PENSION,
                a.INSURANCE_MEDICAL,
                a.INSURANCE_UNEMPLOYMENT,
                a.INSURANCE_INJURY,
                a.INSURANCE_BIRTH,
                a.INSURANCE_BIGAILMENT,
                a.LATEST_CARDINALITY,
                a.IS_ILLNESS,
                a.COLLECT_TYPE,
                a.VALUE_TYPE,
                a.COLLECT_MOTH,
                a.IS_CHARGE_PERSONAL,
                a.RECORD_BASE,
                a.TRUST_REMARK,
                a.PAYMENT_TYPE,
                a.UPPER_LIMIT,
                a.LOWER_LIMIT,
                a.PENSION_START,
                a.MEDICAL_START,
                a.UNEMPLOY_START,
                a.WORK_INJURY_START,
                a.BIRTH_START,
                a.BIGAILMENT_START,
                a.PENSION_HANDLE,
                a.MEDICAL_HANDLE,
                a.UNEMPLOY_HANDLE,
                a.WORK_INJURY_HANDLE,
                a.BIRTH_HANDLE,
                a.BIGAILMENT_HANDLE,
                a.UNIT_PERSION_MONEY,
                a.UNIT_MEDICAL_MONEY,
                a.UNIT_UNEMPLOYMENT_MONEY,
                a.UNIT_INJURY_MONEY,
                a.UNIT_BIRTH_MONEY,
                a.UNIT_BIGAILMENT_MONEY,
                a.PERSONAL_PERSION_MONEY,
                a.PERSONAL_MEDICAL_MONEY,
                a.PERSONAL_UNEMPLOYMENT_MONEY,
                a.PERSONAL_BIGAILMENT_MONEY,
                a.UNIT_PROVIDENG_CARDINAL,
                a.PERSONAL_PROVIDENT_CARDINAL,
                a.SOCIAL_START_DATE,
                a.UNIT_PROVIDENT_PER,
                a.PERSONAL_PROVIDENT_PER,
                a.PROVIDENT_START,
                a.FIRST_BUY_MOTH_FUND,
                a.UPPER_LIMIT_FUND,
                a.LOWER_LIMIT_FUND,
                a.FUND_PAY_POINT,
                a.CAN_OVERPAY_FUND,
                a.OVERPAY_NUMBER_FUND,
                a.PAY_POLICY_FUND,
                a.TRUST_REMARK_FUND,
                a.HAVE_THIS_MONTH_FUND,
                a.LATEST_CARDINALITY_FUND,
				a.FUND_REDUCE_DATE,
				a.PERSONAL_FUND_SUM,
				a.UNIT_FUND_SUM,
				a.UNIT_SOCIAL_SUM,
				a.PERSONAL_SOCIAL_SUM,
				a.UNIT_INTEREST_FEE,
				a.PERSONAL_INTEREST_FEE,
				a.SOCIAL_STATUS,
				a.FUND_STATUS,
				a.DISPATCH_ID
	</sql>

	<!-- 其他地方查询，不需要拼接项目名称 -->
	<sql id="Other_Base_Column_List">
				a.ID,
                a.EMP_ID,
                a.EMP_NO,
                a.EMP_NAME,
                a.EMP_IDCARD,
                a.EMP_TYPE,
                a.SETTLE_DOMAIN,
                a.SETTLE_DOMAIN_CODE,
                a.SETTLE_DOMAIN_NAME,
                a.UNIT_NAME,
                a.UNIT_ID,
 				a.SETTLE_DOMAIN_FUND,
				a.SETTLE_DOMAIN_CODE_FUND,
                a.SETTLE_DOMAIN_NAME_FUND,
                a.UNIT_NAME_FUND,
                a.UNIT_ID_FUND,
                a.SOCIAL_HOUSEHOLD,
                a.SOCIAL_HOUSEHOLD_NAME,
                a.SOCIAL_PROVINCE,
                a.SOCIAL_CITY,
                a.SOCIAL_TOWN,
                a.PROVIDENT_HOUSEHOLD,
                a.PROVIDENT_HOUSEHOLD_NAME,
                a.FUND_PROVINCE,
                a.FUND_CITY,
                a.FUND_TOWN,
                a.SOCIAL_ADD_STATUS,
                a.FUND_ADD_STATUS,
                a.SOCIAL_REDUCE_STATUS,
                a.FUND_REDUCE_STATUS,
                a.SOCIAL_ID,
                a.FUND_ID,
                a.CREATE_BY,
                a.UPDATE_BY,
                a.CREATE_NAME,
                a.UPDATE_TIME,
                a.CREATE_TIME,
                a.FIRST_BUY_MONTH_SOCIAL,
                a.UNIT_PENSION_CARDINAL,
                a.UNIT_MEDICAL_CARDINAL,
                a.UNIT_UNEMPLOYMENT_CARDINAL,
                a.UNIT_BIGAILMENT_CARDINAL,
                a.UNIT_WORK_INJURY_CARDINAL,
                a.UNIT_BIRTH_CARDINAL,
                a.PERSONAL_PENSION_CARDINAL,
                a.PERSONAL_MEDICAL_CARDINAL,
                a.PERSONAL_BIGAILMENT_CARDINAL,
                a.PERSONAL_UNEMPLOYMENT_CARDINAL,
                a.UNIT_PENSION_PER,
                a.UNIT_MEDICAL_PER,
                a.UNIT_UNEMPLOYMENT_PER,
                a.UNIT_WORK_UNJURY_PER,
                a.UNIT_BIRTH_PER,
                a.PERSONAL_PENSION_PER,
                a.PERSONAL_MEDICAL_PER,
                a.PERSONAL_UNEMPLOYMENT_PER,
                a.HANDLE_STATUS,
                a.PERSONAL_BIGAILMENT_PER,
                a.UNIT_BIGAILMENT_PER,
                a.SOCIAL_REDUCE_DATE,
                a.CAN_OVERPAY,
                a.PAY_POLICY,
                a.OVERPAY_NUMBER,
                a.HAVE_THIS_MONTH,
                a.INSURANCE_PENSION,
                a.INSURANCE_MEDICAL,
                a.INSURANCE_UNEMPLOYMENT,
                a.INSURANCE_INJURY,
                a.INSURANCE_BIRTH,
                a.INSURANCE_BIGAILMENT,
                a.LATEST_CARDINALITY,
                a.IS_ILLNESS,
                a.COLLECT_TYPE,
                a.VALUE_TYPE,
                a.COLLECT_MOTH,
                a.IS_CHARGE_PERSONAL,
                a.RECORD_BASE,
                a.TRUST_REMARK,
                a.PAYMENT_TYPE,
                a.UPPER_LIMIT,
                a.LOWER_LIMIT,
                a.PENSION_START,
                a.MEDICAL_START,
                a.UNEMPLOY_START,
                a.WORK_INJURY_START,
                a.BIRTH_START,
                a.BIGAILMENT_START,
                a.PENSION_HANDLE,
                a.MEDICAL_HANDLE,
                a.UNEMPLOY_HANDLE,
                a.WORK_INJURY_HANDLE,
                a.BIRTH_HANDLE,
                a.BIGAILMENT_HANDLE,
                a.UNIT_PERSION_MONEY,
                a.UNIT_MEDICAL_MONEY,
                a.UNIT_UNEMPLOYMENT_MONEY,
                a.UNIT_INJURY_MONEY,
                a.UNIT_BIRTH_MONEY,
                a.UNIT_BIGAILMENT_MONEY,
                a.PERSONAL_PERSION_MONEY,
                a.PERSONAL_MEDICAL_MONEY,
                a.PERSONAL_UNEMPLOYMENT_MONEY,
                a.PERSONAL_BIGAILMENT_MONEY,
                a.UNIT_PROVIDENG_CARDINAL,
                a.PERSONAL_PROVIDENT_CARDINAL,
                a.SOCIAL_START_DATE,
                a.UNIT_PROVIDENT_PER,
                a.PERSONAL_PROVIDENT_PER,
                a.PROVIDENT_START,
                a.FIRST_BUY_MOTH_FUND,
                a.UPPER_LIMIT_FUND,
                a.LOWER_LIMIT_FUND,
                a.FUND_PAY_POINT,
                a.CAN_OVERPAY_FUND,
                a.OVERPAY_NUMBER_FUND,
                a.PAY_POLICY_FUND,
                a.TRUST_REMARK_FUND,
                a.HAVE_THIS_MONTH_FUND,
                a.LATEST_CARDINALITY_FUND,
				a.FUND_REDUCE_DATE,
				a.PERSONAL_FUND_SUM,
				a.UNIT_FUND_SUM,
				a.UNIT_SOCIAL_SUM,
				a.PERSONAL_SOCIAL_SUM,
				a.UNIT_INTEREST_FEE,
				a.PERSONAL_INTEREST_FEE,
				a.SOCIAL_STATUS,
				a.FUND_STATUS,
				a.DISPATCH_ID,a.UNIT_SOCIAL_SUM,a.PERSONAL_SOCIAL_SUM,a.SOCIAL_ID_SUCCESS
	</sql>
	<sql id="tSocialFundInfo_where">
		<if test="tSocialFundInfo != null">
			<if test="tSocialFundInfo.idList != null">
				AND a.ID in
				<foreach item="idStr" index="index" collection="tSocialFundInfo.idList" open="(" separator="," close=")">
					#{idStr}
				</foreach>
			</if>
			<if test="tSocialFundInfo.empTypeList != null and tSocialFundInfo.empTypeList.length>0">
				AND a.EMP_TYPE IN
				<foreach collection="tSocialFundInfo.empTypeList" item="item" index="index" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
			<if test="tSocialFundInfo.id != null and tSocialFundInfo.id.trim() != ''">
				AND a.ID = #{tSocialFundInfo.id}
			</if>
			<if test="tSocialFundInfo.settleDomainCode != null and tSocialFundInfo.settleDomainCode.trim() != ''">
				AND a.SETTLE_DOMAIN_CODE = #{tSocialFundInfo.settleDomainCode}
			</if>

			<if test="tSocialFundInfo.empId != null and tSocialFundInfo.empId.trim() != ''">
				AND a.EMP_ID = #{tSocialFundInfo.empId}
			</if>
			<if test="tSocialFundInfo.empNo != null and tSocialFundInfo.empNo.trim() != ''">
				AND a.EMP_NO = #{tSocialFundInfo.empNo}
			</if>
			<if test="tSocialFundInfo.empName != null and tSocialFundInfo.empName.trim() != ''">
				AND a.EMP_NAME like concat('%',#{tSocialFundInfo.empName},'%')
			</if>
			<if test="tSocialFundInfo.empIdcard != null and tSocialFundInfo.empIdcard.trim() != ''">
				AND a.EMP_IDCARD like concat('%',#{tSocialFundInfo.empIdcard},'%')
			</if>
			<if test="tSocialFundInfo.empType != null and tSocialFundInfo.empType.trim() != ''">
				AND a.EMP_TYPE = #{tSocialFundInfo.empType}
			</if>
			<if test="tSocialFundInfo.settleDomain != null and tSocialFundInfo.settleDomain.trim() != ''">
				AND a.SETTLE_DOMAIN = #{tSocialFundInfo.settleDomain}
			</if>
			<if test="tSocialFundInfo.settleDomainName != null and tSocialFundInfo.settleDomainName.trim() != ''">
				AND (a.SETTLE_DOMAIN_NAME like concat('%',#{tSocialFundInfo.settleDomainName},'%') or a.SETTLE_DOMAIN_NAME_FUND like concat('%',#{tSocialFundInfo.settleDomainName},'%'))
			</if>
			<if test="tSocialFundInfo.unitName != null and tSocialFundInfo.unitName.trim() != ''">
				AND (a.UNIT_NAME like concat('%',#{tSocialFundInfo.unitName},'%') or a.UNIT_NAME_FUND like concat('%',#{tSocialFundInfo.unitName},'%'))
			</if>
			<if test="tSocialFundInfo.unitId != null and tSocialFundInfo.unitId.trim() != ''">
				AND a.UNIT_ID = #{tSocialFundInfo.unitId}
			</if>
			<if test="tSocialFundInfo.socialHousehold != null and tSocialFundInfo.socialHousehold.trim() != ''">
				AND a.SOCIAL_HOUSEHOLD = #{tSocialFundInfo.socialHousehold}
			</if>
			<if test="tSocialFundInfo.socialHouseholdName != null and tSocialFundInfo.socialHouseholdName.trim() != ''">
				AND a.SOCIAL_HOUSEHOLD_NAME = #{tSocialFundInfo.socialHouseholdName}
			</if>
			<if test="tSocialFundInfo.socialProvince != null and tSocialFundInfo.socialProvince.trim() != ''">
				AND a.SOCIAL_PROVINCE = #{tSocialFundInfo.socialProvince}
			</if>
			<if test="tSocialFundInfo.socialCity != null and tSocialFundInfo.socialCity.trim() != ''">
				AND a.SOCIAL_CITY = #{tSocialFundInfo.socialCity}
			</if>
			<if test="tSocialFundInfo.socialTown != null and tSocialFundInfo.socialTown.trim() != ''">
				AND a.SOCIAL_TOWN = #{tSocialFundInfo.socialTown}
			</if>
			<if test="tSocialFundInfo.providentHousehold != null and tSocialFundInfo.providentHousehold.trim() != ''">
				AND a.PROVIDENT_HOUSEHOLD = #{tSocialFundInfo.providentHousehold}
			</if>
			<if test="tSocialFundInfo.providentHouseholdName != null and tSocialFundInfo.providentHouseholdName.trim() != ''">
				AND a.PROVIDENT_HOUSEHOLD_NAME = #{tSocialFundInfo.providentHouseholdName}
			</if>
			<if test="tSocialFundInfo.fundProvince != null and tSocialFundInfo.fundProvince.trim() != ''">
				AND a.FUND_PROVINCE = #{tSocialFundInfo.fundProvince}
			</if>
			<if test="tSocialFundInfo.fundCity != null and tSocialFundInfo.fundCity.trim() != ''">
				AND a.FUND_CITY = #{tSocialFundInfo.fundCity}
			</if>
			<if test="tSocialFundInfo.fundTown != null and tSocialFundInfo.fundTown.trim() != ''">
				AND a.FUND_TOWN = #{tSocialFundInfo.fundTown}
			</if>
			<if test="tSocialFundInfo.socialAddStatus != null and tSocialFundInfo.socialAddStatus.trim() != ''">
				AND a.SOCIAL_ADD_STATUS = #{tSocialFundInfo.socialAddStatus}
			</if>
			<if test="tSocialFundInfo.fundAddStatus != null and tSocialFundInfo.fundAddStatus.trim() != ''">
				AND a.FUND_ADD_STATUS = #{tSocialFundInfo.fundAddStatus}
			</if>
			<if test="tSocialFundInfo.socialReduceStatus != null and tSocialFundInfo.socialReduceStatus.trim() != ''">
				AND a.SOCIAL_REDUCE_STATUS = #{tSocialFundInfo.socialReduceStatus}
			</if>
			<if test="tSocialFundInfo.fundReduceStatus != null and tSocialFundInfo.fundReduceStatus.trim() != ''">
				AND a.FUND_REDUCE_STATUS = #{tSocialFundInfo.fundReduceStatus}
			</if>
			<if test="tSocialFundInfo.socialId != null and tSocialFundInfo.socialId.trim() != ''">
				AND a.SOCIAL_ID = #{tSocialFundInfo.socialId}
			</if>
			<if test="tSocialFundInfo.fundId != null and tSocialFundInfo.fundId.trim() != ''">
				AND a.FUND_ID = #{tSocialFundInfo.fundId}
			</if>
			<if test="tSocialFundInfo.createBy != null and tSocialFundInfo.createBy.trim() != ''">
				AND a.CREATE_BY = #{tSocialFundInfo.createBy}
			</if>
			<if test="tSocialFundInfo.updateBy != null and tSocialFundInfo.updateBy.trim() != ''">
				AND a.UPDATE_BY = #{tSocialFundInfo.updateBy}
			</if>
			<if test="tSocialFundInfo.createName != null and tSocialFundInfo.createName.trim() != ''">
				AND a.CREATE_NAME = #{tSocialFundInfo.createName}
			</if>
			<if test="tSocialFundInfo.updateTime != null">
				AND a.UPDATE_TIME = #{tSocialFundInfo.updateTime}
			</if>
			<if test="tSocialFundInfo.firstBuyMonthSocial != null">
				AND a.FIRST_BUY_MONTH_SOCIAL = #{tSocialFundInfo.firstBuyMonthSocial}
			</if>
			<if test="tSocialFundInfo.unitPensionCardinal != null">
				AND a.UNIT_PENSION_CARDINAL = #{tSocialFundInfo.unitPensionCardinal}
			</if>
			<if test="tSocialFundInfo.unitMedicalCardinal != null">
				AND a.UNIT_MEDICAL_CARDINAL = #{tSocialFundInfo.unitMedicalCardinal}
			</if>
			<if test="tSocialFundInfo.unitUnemploymentCardinal != null">
				AND a.UNIT_UNEMPLOYMENT_CARDINAL = #{tSocialFundInfo.unitUnemploymentCardinal}
			</if>
			<if test="tSocialFundInfo.unitBigailmentCardinal != null">
				AND a.UNIT_BIGAILMENT_CARDINAL = #{tSocialFundInfo.unitBigailmentCardinal}
			</if>
			<if test="tSocialFundInfo.unitWorkInjuryCardinal != null">
				AND a.UNIT_WORK_INJURY_CARDINAL = #{tSocialFundInfo.unitWorkInjuryCardinal}
			</if>
			<if test="tSocialFundInfo.unitBirthCardinal != null">
				AND a.UNIT_BIRTH_CARDINAL = #{tSocialFundInfo.unitBirthCardinal}
			</if>
			<if test="tSocialFundInfo.personalPensionCardinal != null">
				AND a.PERSONAL_PENSION_CARDINAL = #{tSocialFundInfo.personalPensionCardinal}
			</if>
			<if test="tSocialFundInfo.personalMedicalCardinal != null">
				AND a.PERSONAL_MEDICAL_CARDINAL = #{tSocialFundInfo.personalMedicalCardinal}
			</if>
			<if test="tSocialFundInfo.personalBigailmentCardinal != null">
				AND a.PERSONAL_BIGAILMENT_CARDINAL = #{tSocialFundInfo.personalBigailmentCardinal}
			</if>
			<if test="tSocialFundInfo.personalUnemploymentCardinal != null">
				AND a.PERSONAL_UNEMPLOYMENT_CARDINAL = #{tSocialFundInfo.personalUnemploymentCardinal}
			</if>
			<if test="tSocialFundInfo.unitPensionPer != null">
				AND a.UNIT_PENSION_PER = #{tSocialFundInfo.unitPensionPer}
			</if>
			<if test="tSocialFundInfo.unitMedicalPer != null">
				AND a.UNIT_MEDICAL_PER = #{tSocialFundInfo.unitMedicalPer}
			</if>
			<if test="tSocialFundInfo.unitUnemploymentPer != null">
				AND a.UNIT_UNEMPLOYMENT_PER = #{tSocialFundInfo.unitUnemploymentPer}
			</if>
			<if test="tSocialFundInfo.unitWorkUnjuryPer != null">
				AND a.UNIT_WORK_UNJURY_PER = #{tSocialFundInfo.unitWorkUnjuryPer}
			</if>
			<if test="tSocialFundInfo.unitBirthPer != null">
				AND a.UNIT_BIRTH_PER = #{tSocialFundInfo.unitBirthPer}
			</if>
			<if test="tSocialFundInfo.personalPensionPer != null">
				AND a.PERSONAL_PENSION_PER = #{tSocialFundInfo.personalPensionPer}
			</if>
			<if test="tSocialFundInfo.personalMedicalPer != null">
				AND a.PERSONAL_MEDICAL_PER = #{tSocialFundInfo.personalMedicalPer}
			</if>
			<if test="tSocialFundInfo.personalUnemploymentPer != null">
				AND a.PERSONAL_UNEMPLOYMENT_PER = #{tSocialFundInfo.personalUnemploymentPer}
			</if>
			<if test="tSocialFundInfo.handleStatus != null and tSocialFundInfo.handleStatus.trim() != ''">
				AND a.HANDLE_STATUS = #{tSocialFundInfo.handleStatus}
			</if>
			<if test="tSocialFundInfo.personalBigailmentPer != null">
				AND a.PERSONAL_BIGAILMENT_PER = #{tSocialFundInfo.personalBigailmentPer}
			</if>
			<if test="tSocialFundInfo.unitBigailmentPer != null">
				AND a.UNIT_BIGAILMENT_PER = #{tSocialFundInfo.unitBigailmentPer}
			</if>
			<if test="tSocialFundInfo.socialReduceDate != null">
				AND a.SOCIAL_REDUCE_DATE = #{tSocialFundInfo.socialReduceDate}
			</if>
			<if test="tSocialFundInfo.canOverpay != null and tSocialFundInfo.canOverpay.trim() != ''">
				AND a.CAN_OVERPAY = #{tSocialFundInfo.canOverpay}
			</if>
			<if test="tSocialFundInfo.payPolicy != null and tSocialFundInfo.payPolicy.trim() != ''">
				AND a.PAY_POLICY = #{tSocialFundInfo.payPolicy}
			</if>
			<if test="tSocialFundInfo.overpayNumber != null">
				AND a.OVERPAY_NUMBER = #{tSocialFundInfo.overpayNumber}
			</if>
			<if test="tSocialFundInfo.haveThisMonth != null and tSocialFundInfo.haveThisMonth.trim() != ''">
				AND a.HAVE_THIS_MONTH = #{tSocialFundInfo.haveThisMonth}
			</if>
			<if test="tSocialFundInfo.insurancePension != null and tSocialFundInfo.insurancePension.trim() != ''">
				AND a.INSURANCE_PENSION = #{tSocialFundInfo.insurancePension}
			</if>
			<if test="tSocialFundInfo.insuranceMedical != null and tSocialFundInfo.insuranceMedical.trim() != ''">
				AND a.INSURANCE_MEDICAL = #{tSocialFundInfo.insuranceMedical}
			</if>
			<if test="tSocialFundInfo.insuranceUnemployment != null and tSocialFundInfo.insuranceUnemployment.trim() != ''">
				AND a.INSURANCE_UNEMPLOYMENT = #{tSocialFundInfo.insuranceUnemployment}
			</if>
			<if test="tSocialFundInfo.insuranceInjury != null and tSocialFundInfo.insuranceInjury.trim() != ''">
				AND a.INSURANCE_INJURY = #{tSocialFundInfo.insuranceInjury}
			</if>
			<if test="tSocialFundInfo.insuranceBirth != null and tSocialFundInfo.insuranceBirth.trim() != ''">
				AND a.INSURANCE_BIRTH = #{tSocialFundInfo.insuranceBirth}
			</if>
			<if test="tSocialFundInfo.insuranceBigailment != null and tSocialFundInfo.insuranceBigailment.trim() != ''">
				AND a.INSURANCE_BIGAILMENT = #{tSocialFundInfo.insuranceBigailment}
			</if>
			<if test="tSocialFundInfo.latestCardinality != null and tSocialFundInfo.latestCardinality.trim() != ''">
				AND a.LATEST_CARDINALITY = #{tSocialFundInfo.latestCardinality}
			</if>
			<if test="tSocialFundInfo.isIllness != null and tSocialFundInfo.isIllness.trim() != ''">
				AND a.IS_ILLNESS = #{tSocialFundInfo.isIllness}
			</if>
			<if test="tSocialFundInfo.collectType != null and tSocialFundInfo.collectType.trim() != ''">
				AND a.COLLECT_TYPE = #{tSocialFundInfo.collectType}
			</if>
			<if test="tSocialFundInfo.valueType != null and tSocialFundInfo.valueType.trim() != ''">
				AND a.VALUE_TYPE = #{tSocialFundInfo.valueType}
			</if>
			<if test="tSocialFundInfo.collectMoth != null">
				AND a.COLLECT_MOTH = #{tSocialFundInfo.collectMoth}
			</if>
			<if test="tSocialFundInfo.isChargePersonal != null and tSocialFundInfo.isChargePersonal.trim() != ''">
				AND a.IS_CHARGE_PERSONAL = #{tSocialFundInfo.isChargePersonal}
			</if>
			<if test="tSocialFundInfo.recordBase != null and tSocialFundInfo.recordBase.trim() != ''">
				AND a.RECORD_BASE = #{tSocialFundInfo.recordBase}
			</if>
			<if test="tSocialFundInfo.trustRemark != null and tSocialFundInfo.trustRemark.trim() != ''">
				AND a.TRUST_REMARK = #{tSocialFundInfo.trustRemark}
			</if>
			<if test="tSocialFundInfo.paymentType != null and tSocialFundInfo.paymentType.trim() != ''">
				AND a.PAYMENT_TYPE = #{tSocialFundInfo.paymentType}
			</if>
			<if test="tSocialFundInfo.upperLimit != null">
				AND a.UPPER_LIMIT = #{tSocialFundInfo.upperLimit}
			</if>
			<if test="tSocialFundInfo.lowerLimit != null">
				AND a.LOWER_LIMIT = #{tSocialFundInfo.lowerLimit}
			</if>
			<if test="tSocialFundInfo.pensionStart != null">
				AND a.PENSION_START = #{tSocialFundInfo.pensionStart}
			</if>
			<if test="tSocialFundInfo.medicalStart != null">
				AND a.MEDICAL_START = #{tSocialFundInfo.medicalStart}
			</if>
			<if test="tSocialFundInfo.unemployStart != null">
				AND a.UNEMPLOY_START = #{tSocialFundInfo.unemployStart}
			</if>
			<if test="tSocialFundInfo.workInjuryStart != null">
				AND a.WORK_INJURY_START = #{tSocialFundInfo.workInjuryStart}
			</if>
			<if test="tSocialFundInfo.birthStart != null">
				AND a.BIRTH_START = #{tSocialFundInfo.birthStart}
			</if>
			<if test="tSocialFundInfo.bigailmentStart != null">
				AND a.BIGAILMENT_START = #{tSocialFundInfo.bigailmentStart}
			</if>
			<if test="tSocialFundInfo.pensionHandle != null and tSocialFundInfo.pensionHandle.trim() != ''">
				AND a.PENSION_HANDLE = #{tSocialFundInfo.pensionHandle}
			</if>
			<if test="tSocialFundInfo.medicalHandle != null and tSocialFundInfo.medicalHandle.trim() != ''">
				AND a.MEDICAL_HANDLE = #{tSocialFundInfo.medicalHandle}
			</if>
			<if test="tSocialFundInfo.unemployHandle != null and tSocialFundInfo.unemployHandle.trim() != ''">
				AND a.UNEMPLOY_HANDLE = #{tSocialFundInfo.unemployHandle}
			</if>
			<if test="tSocialFundInfo.workInjuryHandle != null and tSocialFundInfo.workInjuryHandle.trim() != ''">
				AND a.WORK_INJURY_HANDLE = #{tSocialFundInfo.workInjuryHandle}
			</if>
			<if test="tSocialFundInfo.birthHandle != null and tSocialFundInfo.birthHandle.trim() != ''">
				AND a.BIRTH_HANDLE = #{tSocialFundInfo.birthHandle}
			</if>
			<if test="tSocialFundInfo.bigailmentHandle != null and tSocialFundInfo.bigailmentHandle.trim() != ''">
				AND a.BIGAILMENT_HANDLE = #{tSocialFundInfo.bigailmentHandle}
			</if>
			<if test="tSocialFundInfo.unitPersionMoney != null">
				AND a.UNIT_PERSION_MONEY = #{tSocialFundInfo.unitPersionMoney}
			</if>
			<if test="tSocialFundInfo.unitMedicalMoney != null">
				AND a.UNIT_MEDICAL_MONEY = #{tSocialFundInfo.unitMedicalMoney}
			</if>
			<if test="tSocialFundInfo.unitUnemploymentMoney != null">
				AND a.UNIT_UNEMPLOYMENT_MONEY = #{tSocialFundInfo.unitUnemploymentMoney}
			</if>
			<if test="tSocialFundInfo.unitInjuryMoney != null">
				AND a.UNIT_INJURY_MONEY = #{tSocialFundInfo.unitInjuryMoney}
			</if>
			<if test="tSocialFundInfo.unitBirthMoney != null">
				AND a.UNIT_BIRTH_MONEY = #{tSocialFundInfo.unitBirthMoney}
			</if>
			<if test="tSocialFundInfo.unitBigailmentMoney != null">
				AND a.UNIT_BIGAILMENT_MONEY = #{tSocialFundInfo.unitBigailmentMoney}
			</if>
			<if test="tSocialFundInfo.personalPersionMoney != null">
				AND a.PERSONAL_PERSION_MONEY = #{tSocialFundInfo.personalPersionMoney}
			</if>
			<if test="tSocialFundInfo.personalMedicalMoney != null">
				AND a.PERSONAL_MEDICAL_MONEY = #{tSocialFundInfo.personalMedicalMoney}
			</if>
			<if test="tSocialFundInfo.personalUnemploymentMoney != null">
				AND a.PERSONAL_UNEMPLOYMENT_MONEY = #{tSocialFundInfo.personalUnemploymentMoney}
			</if>
			<if test="tSocialFundInfo.personalBigailmentMoney != null">
				AND a.PERSONAL_BIGAILMENT_MONEY = #{tSocialFundInfo.personalBigailmentMoney}
			</if>
			<if test="tSocialFundInfo.unitProvidengCardinal != null">
				AND a.UNIT_PROVIDENG_CARDINAL = #{tSocialFundInfo.unitProvidengCardinal}
			</if>
			<if test="tSocialFundInfo.personalProvidentCardinal != null">
				AND a.PERSONAL_PROVIDENT_CARDINAL = #{tSocialFundInfo.personalProvidentCardinal}
			</if>
			<if test="tSocialFundInfo.socialStartDate != null">
				AND a.SOCIAL_START_DATE = #{tSocialFundInfo.socialStartDate}
			</if>
			<if test="tSocialFundInfo.unitProvidentPer != null">
				AND a.UNIT_PROVIDENT_PER = #{tSocialFundInfo.unitProvidentPer}
			</if>
			<if test="tSocialFundInfo.personalProvidentPer != null">
				AND a.PERSONAL_PROVIDENT_PER = #{tSocialFundInfo.personalProvidentPer}
			</if>
			<if test="tSocialFundInfo.providentStart != null">
				AND a.PROVIDENT_START = #{tSocialFundInfo.providentStart}
			</if>
			<if test="tSocialFundInfo.firstBuyMothFund != null">
				AND a.FIRST_BUY_MOTH_FUND = #{tSocialFundInfo.firstBuyMothFund}
			</if>
			<if test="tSocialFundInfo.upperLimitFund != null">
				AND a.UPPER_LIMIT_FUND = #{tSocialFundInfo.upperLimitFund}
			</if>
			<if test="tSocialFundInfo.lowerLimitFund != null">
				AND a.LOWER_LIMIT_FUND = #{tSocialFundInfo.lowerLimitFund}
			</if>
			<if test="tSocialFundInfo.fundPayPoint != null and tSocialFundInfo.fundPayPoint.trim() != ''">
				AND a.FUND_PAY_POINT = #{tSocialFundInfo.fundPayPoint}
			</if>
			<if test="tSocialFundInfo.canOverpayFund != null and tSocialFundInfo.canOverpayFund.trim() != ''">
				AND a.CAN_OVERPAY_FUND = #{tSocialFundInfo.canOverpayFund}
			</if>
			<if test="tSocialFundInfo.overpayNumberFund != null">
				AND a.OVERPAY_NUMBER_FUND = #{tSocialFundInfo.overpayNumberFund}
			</if>
			<if test="tSocialFundInfo.payPolicyFund != null and tSocialFundInfo.payPolicyFund.trim() != ''">
				AND a.PAY_POLICY_FUND = #{tSocialFundInfo.payPolicyFund}
			</if>
			<if test="tSocialFundInfo.trustRemarkFund != null and tSocialFundInfo.trustRemarkFund.trim() != ''">
				AND a.TRUST_REMARK_FUND = #{tSocialFundInfo.trustRemarkFund}
			</if>
			<if test="tSocialFundInfo.haveThisMonthFund != null and tSocialFundInfo.haveThisMonthFund.trim() != ''">
				AND a.HAVE_THIS_MONTH_FUND = #{tSocialFundInfo.haveThisMonthFund}
			</if>
			<if test="tSocialFundInfo.latestCardinalityFund != null and tSocialFundInfo.latestCardinalityFund.trim() != ''">
				AND a.LATEST_CARDINALITY_FUND = #{tSocialFundInfo.latestCardinalityFund}
			</if>
			<if test="tSocialFundInfo.socialStatus != null and tSocialFundInfo.socialStatus.trim() != ''">
				AND a.SOCIAL_STATUS = #{tSocialFundInfo.socialStatus}
			</if>
			<if test="tSocialFundInfo.fundStatus != null and tSocialFundInfo.fundStatus.trim() != ''">
				AND a.FUND_STATUS = #{tSocialFundInfo.fundStatus}
			</if>
			<if test="tSocialFundInfo.authSql != null and tSocialFundInfo.authSql.trim() != ''">
				${tSocialFundInfo.authSql}
			</if>
		</if>
	</sql>
	<!--tSocialFundInfo简单分页查询-->
	<select id="getTSocialFundInfoPage" resultMap="tSocialFundInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_social_fund_info a
		<where>
			1=1
			<include refid="tSocialFundInfo_where"/>
		</where>
		<!--group by a.id-->
		order by a.CREATE_TIME desc
	</select>

	<!--获取在用社保 #a.SOCIAL_ADD_STATUS != '4' and a.SOCIAL_REDUCE_STATUS != '2' -->
	<select id="getSocialList" resultMap="tSocialFundInfoMap">
		SELECT
		<include refid="Other_Base_Column_List"/>
		FROM t_social_fund_info a
		<where>
			a.SOCIAL_ID is not null
			<if test="empIdCard != null">
				and a.EMP_IDCARD = #{empIdCard}
			</if>
			<if test="settleDomainIds != null">
				AND a.SETTLE_DOMAIN in
				<foreach item="item" index="index" collection="settleDomainIds" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
		</where>
	</select>
	<!--获取在用公积金 a.FUND_ADD_STATUS != '4' and a.FUND_REDUCE_STATUS != '2' -->
	<select id="getFundList" resultMap="tSocialFundInfoMap">
		SELECT
		<include refid="Other_Base_Column_List"/>
		FROM t_social_fund_info a
		<where>
			a.FUND_ID is not null
			<if test="empIdCard != null">
				and a.EMP_IDCARD = #{empIdCard}
			</if>
			<if test="settleDomainIds != null">
				AND a.SETTLE_DOMAIN in
				<foreach item="item" index="index" collection="settleDomainIds" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
		</where>
	</select>

	<!--导出-->
	<select id="exportListCount" resultType="java.lang.Integer">
		select
		count(1)
		from t_social_fund_info a
		<where>
			1=1
			<include refid="tSocialFundInfo_where"/>
		</where>
	</select>

	<!--导出-->
	<select id="exportList" resultMap="exportMap">
		select
		a.ID,
		a.EMP_NAME,
		a.EMP_IDCARD,
		case when a.EMP_TYPE = 0 then "外包"
		when a.EMP_TYPE = 1 then "派遣"
		when a.EMP_TYPE = 2 then "代理"
		when a.EMP_TYPE = 3 then "内部员工"
		else null  end  as  "EMP_TYPE" ,
		d.EMP_MOBILE,
		if(a.SETTLE_DOMAIN_CODE = a.SETTLE_DOMAIN_CODE_FUND,a.SETTLE_DOMAIN_CODE,concat(ifnull(a.SETTLE_DOMAIN_CODE,""),if(a.SETTLE_DOMAIN_CODE is null or a.SETTLE_DOMAIN_CODE_FUND is null,"",","),ifnull(a.SETTLE_DOMAIN_CODE_FUND,""))) SETTLE_DOMAIN_CODE,
		if(a.SETTLE_DOMAIN_NAME = a.SETTLE_DOMAIN_NAME_FUND,a.SETTLE_DOMAIN_NAME,concat(ifnull(a.SETTLE_DOMAIN_NAME,""),if(a.SETTLE_DOMAIN_NAME is null or a.SETTLE_DOMAIN_NAME_FUND is null,"",","),ifnull(a.SETTLE_DOMAIN_NAME_FUND,""))) SETTLE_DOMAIN_NAME,
		if(a.UNIT_NAME = a.UNIT_NAME_FUND,a.UNIT_NAME,concat(ifnull(a.UNIT_NAME,""),if(a.UNIT_NAME is null or a.UNIT_NAME_FUND is null,"",","),ifnull(a.UNIT_NAME_FUND,""))) UNIT_NAME,
		a1.AREA_NAME as "ID_CARD_PROVINCE",
		a2.AREA_NAME as "ID_CARD_CITY",
		a3.AREA_NAME as "ID_CARD_TOWN",
		d.ID_CARD_ADDRESS,
		d1.AREA_NAME as "FILE_PROVINCE",
		d2.AREA_NAME as "FILE_CITY",
		d3.AREA_NAME as "FILE_TOWN",
		d.POST,
		d.TRY_PERIOD,
		case when d.WORKING_HOURS = 1 then "标准工时"
		when d.WORKING_HOURS = 2 then "综合工时"
		when d.WORKING_HOURS = 3 then "不定时工时制"
		else null  end  as  "WORKING_HOURS" ,
		d.CONTRACT_NAME,
		d.CONTRACT_SUB_NAME,
		a.SOCIAL_HOUSEHOLD_NAME CONTRACT_PARTY,
		d.CONTRACT_TYPE,
		d.CONTRACT_START,
		d.CONTRACT_END,
		d.CONTRACT_TERM,
		d.EDUCATION_NAME,
		a.RECORD_BASE,
		<!--"社保状态：派增（0待审核、1待办理、2办理中 3办理成功、4部分办理失败 5 办理失败 10 审核不通过）、派减（6待审核 7待办理 8办理成功 9 办理失败  11 派减办理中 12 派减部分办理失败）" ) -->
		case when a.SOCIAL_STATUS = 0 then "派增待审核"
		when a.SOCIAL_STATUS = 1 then "派增待办理"
		when a.SOCIAL_STATUS = 2 then "派增办理中"
		when a.SOCIAL_STATUS = 3 then "派增办理成功"
		when a.SOCIAL_STATUS = 4 then "派增部分办理失败"
		when a.SOCIAL_STATUS = 5 then "派增办理失败"
		when a.SOCIAL_STATUS = 6 then "派减待审核"
		when a.SOCIAL_STATUS = 7 then "派减待办理"
		when a.SOCIAL_STATUS = 8 then "派减办理成功"
		when a.SOCIAL_STATUS = 9 then "派减办理失败"
		when a.SOCIAL_STATUS = 10 then "派增审核不通过"
		WHEN a.SOCIAL_STATUS = 11 THEN "派减办理中"
		WHEN a.SOCIAL_STATUS = 12 THEN "派减部分办理失败"
		else null  end  as  "SOCIAL_STATUS" ,
		case when a.FUND_STATUS = 0 then "派增待审核"
		when a.FUND_STATUS = 1 then "派增待办理"
		when a.FUND_STATUS = 3 then "派增办理成功"
		when a.FUND_STATUS = 4 then "派增办理失败"
		when a.FUND_STATUS = 5 then "派减待审核"
		when a.FUND_STATUS = 6 then "派减待办理"
		when a.FUND_STATUS = 7 then "派减办理成功"
		when a.FUND_STATUS = 8 then "派减办理失败"
		when a.FUND_STATUS = 9 then "派增审核不通过"
		else null  end  as  "FUND_STATUS" ,
		a.SOCIAL_START_DATE,
		a.PROVIDENT_START,
		a.SOCIAL_REDUCE_DATE,
		a.FUND_REDUCE_DATE,
		a.UNIT_SOCIAL_SUM,
		a.PERSONAL_SOCIAL_SUM,
		a.UNIT_FUND_SUM,
		a.PERSONAL_FUND_SUM,
		ifnull(a.UNIT_SOCIAL_SUM,0) + ifnull(a.PERSONAL_SOCIAL_SUM,0) + ifnull(a.UNIT_FUND_SUM,0) + ifnull(a.PERSONAL_FUND_SUM,0) ALL_SUM,
		a.SOCIAL_HOUSEHOLD_NAME,
		s1.AREA_NAME as "SOCIAL_PROVINCE",
		s2.AREA_NAME as "SOCIAL_CITY",
		s3.AREA_NAME as "SOCIAL_TOWN",
		a.PENSION_START,
		a.MEDICAL_START,
		a.UNEMPLOY_START,
		a.WORK_INJURY_START,
		a.BIRTH_START,
		a.BIGAILMENT_START,
		case when a.PAYMENT_TYPE = 0 then "最低"
		when a.PAYMENT_TYPE = 1 then "自定义"
		when a.PAYMENT_TYPE = 2 then "最高"
		else null  end  as  "PAYMENT_TYPE" ,

		a.UNIT_PENSION_CARDINAL,
		a.UNIT_PENSION_PER,
		a.PERSONAL_PENSION_PER,
		a.UNIT_PERSION_MONEY,
		a.PERSONAL_PERSION_MONEY,
		ifnull(a.UNIT_PERSION_MONEY,0) + ifnull(a.PERSONAL_PERSION_MONEY,0) PERSION_MONEY,

		a.UNIT_MEDICAL_CARDINAL,
		a.UNIT_MEDICAL_PER,
		a.PERSONAL_MEDICAL_PER,
		a.UNIT_MEDICAL_MONEY,
		a.PERSONAL_MEDICAL_MONEY,
		ifnull(a.UNIT_MEDICAL_MONEY,0) + ifnull(a.PERSONAL_MEDICAL_MONEY,0) MEDICAL_MONEY,

		a.UNIT_UNEMPLOYMENT_CARDINAL,
		a.UNIT_UNEMPLOYMENT_PER,
		a.PERSONAL_UNEMPLOYMENT_PER,
		a.UNIT_UNEMPLOYMENT_MONEY,
		a.PERSONAL_UNEMPLOYMENT_MONEY,
		ifnull(a.UNIT_UNEMPLOYMENT_MONEY,0) + ifnull(a.PERSONAL_UNEMPLOYMENT_MONEY,0) UNEMPLOYMENT_MONEY,

		a.UNIT_WORK_INJURY_CARDINAL,
		a.UNIT_WORK_UNJURY_PER,
		a.UNIT_INJURY_MONEY,

		a.UNIT_BIRTH_CARDINAL,
		a.UNIT_BIRTH_PER,
		a.UNIT_BIRTH_MONEY,

		a.UNIT_BIGAILMENT_CARDINAL,
		a.UNIT_BIGAILMENT_PER,
		a.PERSONAL_BIGAILMENT_PER,
		a.UNIT_BIGAILMENT_MONEY,
		a.PERSONAL_BIGAILMENT_MONEY,
		ifnull(a.UNIT_BIGAILMENT_MONEY,0) + ifnull(a.PERSONAL_BIGAILMENT_MONEY,0) BIGAILMENT_MONEY,

		a.PROVIDENT_HOUSEHOLD_NAME,
		f1.AREA_NAME as "FUND_PROVINCE",
		f2.AREA_NAME as "FUND_CITY",
		f3.AREA_NAME as "FUND_TOWN",
		a.UNIT_PROVIDENG_CARDINAL,
		a.UNIT_PROVIDENT_PER,
		a.PERSONAL_PROVIDENT_PER,
		a.UNIT_FUND_SUM UNIT_FUND_SUM2,
		a.PERSONAL_FUND_SUM PERSONAL_FUND_SUM2,
		ifnull(a.UNIT_FUND_SUM,0) + ifnull(a.PERSONAL_FUND_SUM,0) FUND_SUM,
		a.TRUST_REMARK,
		case when a.PENSION_HANDLE = 0 then "待办理"
		when a.PENSION_HANDLE = 1 then "办理成功"
		when a.PENSION_HANDLE = 2 then "办理失败"
		when a.PENSION_HANDLE = 3 then "已派减"
		else null  end  as  "PENSION_HANDLE" ,
		case when a.MEDICAL_HANDLE = 0 then "待办理"
		when a.MEDICAL_HANDLE = 1 then "办理成功"
		when a.MEDICAL_HANDLE = 2 then "办理失败"
		when a.MEDICAL_HANDLE = 3 then "已派减"
		else null  end  as  "MEDICAL_HANDLE" ,
		case when a.UNEMPLOY_HANDLE = 0 then "待办理"
		when a.UNEMPLOY_HANDLE = 1 then "办理成功"
		when a.UNEMPLOY_HANDLE = 2 then "办理失败"
		when a.UNEMPLOY_HANDLE = 3 then "已派减"
		else null  end  as  "UNEMPLOY_HANDLE" ,
		case when a.WORK_INJURY_HANDLE = 0 then "待办理"
		when a.WORK_INJURY_HANDLE = 1 then "办理成功"
		when a.WORK_INJURY_HANDLE = 2 then "办理失败"
		when a.WORK_INJURY_HANDLE = 3 then "已派减"
		else null  end  as  "WORK_INJURY_HANDLE" ,
		case when a.BIRTH_HANDLE = 0 then "待办理"
		when a.BIRTH_HANDLE = 1 then "办理成功"
		when a.BIRTH_HANDLE = 2 then "办理失败"
		when a.BIRTH_HANDLE = 3 then "已派减"
		else null  end  as  "BIRTH_HANDLE" ,
		case when a.BIGAILMENT_HANDLE = 0 then "待办理"
		when a.BIGAILMENT_HANDLE = 1 then "办理成功"
		when a.BIGAILMENT_HANDLE = 2 then "办理失败"
		when a.BIGAILMENT_HANDLE = 3 then "已派减"
		else null  end  as  "BIGAILMENT_HANDLE" ,
		d.EMP_NATIONAL,
		d.EMP_REGIS_TYPE
		from t_social_fund_info a
		left join t_dispatch_info d on a.DISPATCH_ID=d.ID
		LEFT JOIN sys_area a1 on d.ID_CARD_PROVINCE=a1.id
		LEFT JOIN sys_area a2 on d.ID_CARD_CITY=a2.id
		LEFT JOIN sys_area a3 on d.ID_CARD_TOWN=a3.id
		LEFT JOIN sys_area s1 on a.SOCIAL_PROVINCE=s1.id
		LEFT JOIN sys_area s2 on a.SOCIAL_CITY=s2.id
		LEFT JOIN sys_area s3 on a.SOCIAL_TOWN=s3.id
		LEFT JOIN sys_area f1 on a.FUND_PROVINCE=f1.id
		LEFT JOIN sys_area f2 on a.FUND_CITY=f2.id
		LEFT JOIN sys_area f3 on a.FUND_TOWN=f3.id
		LEFT JOIN sys_area d1 on d.FILE_PROVINCE=d1.id
		LEFT JOIN sys_area d2 on d.FILE_CITY=d2.id
		LEFT JOIN sys_area d3 on d.FILE_TOWN=d3.id

		<where>
			1=1
			<include refid="tSocialFundInfo_where"/>
		</where>
		order by a.CREATE_TIME desc
		<if test="tSocialFundInfo.limitStart != null">
			limit #{tSocialFundInfo.limitStart},#{tSocialFundInfo.limitEnd}
		</if>
	</select>
	<update id="updateSocialAndFoundInfo">
		update t_social_fund_info
		set UNIT_ID            = #{infoVo.unitId},
			UNIT_NAME          = #{infoVo.unitName},
			SETTLE_DOMAIN_NAME = #{infoVo.settleDomainName},
			SETTLE_DOMAIN_CODE = #{infoVo.settleDomainCode},
			SETTLE_DOMAIN   = #{infoVo.settleDomainId}
		where EMP_IDCARD = #{infoVo.empIdcard}
	</update>
	<update id="updateSocialAndFoundInfoF">
		update t_social_fund_info
		set UNIT_ID_FUND            = #{infoVo.unitId},
			UNIT_NAME_FUND          = #{infoVo.unitName},
			SETTLE_DOMAIN_NAME_FUND = #{infoVo.settleDomainName},
			SETTLE_DOMAIN_CODE_FUND = #{infoVo.settleDomainCode},
			SETTLE_DOMAIN_FUND   = #{infoVo.settleDomainId}
		where EMP_IDCARD = #{infoVo.empIdcard}
	</update>

	<update id="updateSocialInfo">
		update t_social_info
		set SETTLE_DOMAIN   = #{infoVo.settleDomainId},
			SETTLE_DOMAIN_CODE = #{infoVo.settleDomainCode}
		where EMP_IDCARD = #{infoVo.empIdcard} and SETTLE_DOMAIN   = #{infoVo.oldDeptId}
	</update>
	<update id="updateFundInfo">
		update t_provident_fund
		set SETTLE_DOMAIN   = #{infoVo.settleDomainId},
			SETTLE_DOMAIN_CODE = #{infoVo.settleDomainCode}
		where EMP_IDCARD = #{infoVo.empIdcard} and SETTLE_DOMAIN   = #{infoVo.oldDeptId}
	</update>

	<!--获取count，合同使用-->
	<select id="selectSocialByContract" resultType="java.lang.String">
		SELECT
			HANDLE_STATUS
		FROM t_social_info a
		where a.EMP_IDCARD = #{tSocialFundInfo.empIdcard} and a.SETTLE_DOMAIN = #{tSocialFundInfo.settleDomain} ORDER BY a.CREATE_TIME desc limit 1
	</select>

	<!--获取count，合同使用-->
	<select id="selectFundByContract" resultType="java.lang.String">
		SELECT
			HANDLE_STATUS
		FROM t_provident_fund a
		where a.EMP_IDCARD = #{tSocialFundInfo.empIdcard} and a.SETTLE_DOMAIN = #{tSocialFundInfo.settleDomain} ORDER BY a.CREATE_TIME desc limit 1
	</select>

	<!-- 获取在保的全量数据，定时任务处理不购买商险 -->
	<select id="getSocialWorkInjuryList" resultType="java.lang.String">
		SELECT EMP_IDCARD FROM t_social_fund_info s where s.WORK_INJURY_HANDLE in ('0','1','4','5')
	</select>

	<!--tSocialFundInfo简单分页查询-->
	<select id="selectUnSocialFundInfoByEmpIdcard" resultMap="unSocialFundInfoMap">
		SELECT a.ID,
			a.SOCIAL_HOUSEHOLD_NAME,
			a.PAYMENT_TYPE,
			a.SOCIAL_STATUS,
			a.SETTLE_DOMAIN_CODE,
			a.SETTLE_DOMAIN_NAME,
			a.SOCIAL_PROVINCE,
			a.SOCIAL_CITY,
			a.SOCIAL_TOWN,
			d.CREATE_NAME as dispatchName,
			a.PENSION_START,
			a.MEDICAL_START,
			a.UNEMPLOY_START,
			a.WORK_INJURY_START,
			a.BIRTH_START,
			a.BIGAILMENT_START,
			a.RECORD_BASE,
			a.TRUST_REMARK,
			DATE_FORMAT(d.CREATE_TIME, '%Y-%m-%d %H:%i:%s') as dispatchTime
		FROM t_social_fund_info a
		inner join
		(
		SELECT
			t.CREATE_NAME,t.CREATE_TIME,t.EMP_IDCARD
			FROM
			t_dispatch_info t
			WHERE
			t.DELETE_FLAG = '0'
			AND t.type = '0'
			AND t.SOCIAL_ID IS NOT NULL
			AND t.`STATUS` != '3'
			<!-- 社保办理状态 0 未办理 1 全部办理成功(原-已办理) 2 全部办理失败（原-办理失败）  3 部分办理成功 4 办理中  -->
			AND t.SOCIAL_HANDLE_STATUS IN ('0','1','3','4')
			AND t.EMP_IDCARD =#{empIdcard}
		<if test="dispatchId != null and dispatchId != ''">
			AND t.id != #{dispatchId}
		</if>
		)  d on a.EMP_IDCARD = d.EMP_IDCARD
		where a.EMP_IDCARD = #{empIdcard}
		  <!-- 社保状态：派增（0待审核、1待办理、2办理中 3办理成功、4部分办理失败 5 办理失败 10 审核不通过）、派减（6待审核 7待办理 8办理成功 9 办理失败 11派减办理中 12 派减部分办理失败） -->
		  and a.social_status in ('0', '1', '2', '3', '4', '6', '7', '9', '11', '12')
		group by a.ID
	</select>
	<!--tSocialFundInfo简单分页查询-->
	<select id="selectUnFundInfoByEmpIdcard" resultMap="unFundInfoMap">
		SELECT a.ID,
			a.PROVIDENT_HOUSEHOLD_NAME,
			'1' as 'PAYMENT_TYPE',
			a.FUND_STATUS,
			a.SETTLE_DOMAIN_CODE_FUND,
			a.SETTLE_DOMAIN_NAME_FUND,
			a.FUND_PROVINCE,
			a.FUND_CITY,
			a.FUND_TOWN,
			d.CREATE_NAME as dispatchName,
			DATE_FORMAT(d.CREATE_TIME, '%Y-%m-%d %H:%i:%s') as dispatchTime,
			a.UNIT_PROVIDENT_PER,
			a.PERSONAL_PROVIDENT_PER,
			a.PROVIDENT_START,
			a.UNIT_PROVIDENG_CARDINAL
		FROM t_social_fund_info a
		inner join (
		SELECT
			t.CREATE_NAME,t.CREATE_TIME,t.EMP_IDCARD
			FROM
			t_dispatch_info t
			WHERE
			t.DELETE_FLAG = '0'
			AND t.type = '0'
			AND t.FUND_ID IS NOT NULL
			AND t.`STATUS` != '3'
			<!-- 公积金办理状态:0 未办理 1办理成功 2 办理失败  -->
			AND t.FUND_HANDLE_STATUS IN ('0','1')
			AND t.EMP_IDCARD =#{empIdcard}
		<if test="dispatchId != null and dispatchId != ''">
			AND t.id != #{dispatchId}
		</if>
		) d on a.EMP_IDCARD = d.EMP_IDCARD
		where a.EMP_IDCARD = #{empIdcard}
		  <!-- 派增（0待审核、1待办理、3办理成功、4办理失败9 审核不通过）、派减（5待审核 6待办理 7 办理成功 8 办理失败 ） -->
		  and a.fund_status in ('0', '1',  '3',  '5', '6', '8')
		group by a.ID
	</select>
	<select id="selectSocialFundInfoCountByEmpIdcard" resultType="java.lang.Long">
		SELECT count(1)
			FROM t_social_fund_info a
					 inner join t_dispatch_info d on a.DISPATCH_ID = d.ID
			where a.EMP_IDCARD = #{empIdcard}
			  <!-- 社保状态：派增（0待审核、1待办理、2办理中 3办理成功、4部分办理失败 5 办理失败 10 审核不通过）、派减（6待审核 7待办理 8办理成功 9 办理失败 11派减办理中 12 派减部分办理失败） -->
		 	and a.social_status in ('0', '1', '2', '3', '4', '6', '7', '9', '11', '12')
	</select>

	<select id="selectFundCountByEmpIdcard" resultType="java.lang.Long">
		SELECT count(1)
		FROM t_social_fund_info a
		where a.EMP_IDCARD = #{empIdcard}
		  <!-- 公积金状态：派增（0待审核、1待办理、3办理成功、4办理失败9 审核不通过）、派减（5待审核 6待办理 7 办理成功 8 办理失败 ） -->
		  and a.fund_status in ('0', '1',  '3', '5', '6', '8')
	</select>


	<select id="getSocialStatus" resultMap="tSocialFundInfoMap">
		SELECT d.id DISPATCH_ID,a.SOCIAL_STATUS
		FROM t_social_fund_info a
				 LEFT JOIN t_dispatch_info d on d.SOCIAL_ID = a.SOCIAL_ID
		where a.EMP_IDCARD = #{empIdCard}
		  and a.SETTLE_DOMAIN_CODE = #{deptNo}
		  and a.SOCIAL_STATUS in ('3','4')
			limit 1
	</select>

	<select id="getFundStatus" resultMap="tSocialFundInfoMap">
		SELECT d.id DISPATCH_ID,a.FUND_STATUS
		FROM t_social_fund_info a
				 LEFT JOIN t_dispatch_info d on d.FUND_ID = a.FUND_ID
		where a.EMP_IDCARD = #{empIdCard}
		  and a.SETTLE_DOMAIN_CODE_FUND = #{deptNo}
		  and a.FUND_STATUS = '3'
			limit 1
	</select>

	<select id="getSocialStatusByClose" resultType="java.lang.String">
		SELECT d.id DISPATCH_ID
		FROM t_social_fund_info a
				 LEFT JOIN t_dispatch_info d on d.SOCIAL_ID = a.SOCIAL_ID
		where a.EMP_IDCARD = #{empIdCard}
		  and a.SETTLE_DOMAIN_CODE = #{deptNo}
		  and a.SOCIAL_STATUS = '8'
		  and d.type = '1'
		limit 1
	</select>

	<select id="getFundStatusByClose" resultType="java.lang.String">
		SELECT d.id DISPATCH_ID
		FROM t_social_fund_info a
				 LEFT JOIN t_dispatch_info d on d.FUND_ID = a.FUND_ID
		where a.EMP_IDCARD = #{empIdCard}
		  and a.SETTLE_DOMAIN_CODE_FUND = #{deptNo}
		  and a.FUND_STATUS = '7'
		  and d.type = '1'
			limit 1
	</select>

</mapper>
