<?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.salary.mapper.TSalaryStandardMapper">

  <resultMap id="tSalaryStandardMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandard">
    <id property="id" column="ID"/>
    <result property="deptId" column="DEPT_ID"/>
    <result property="deptName" column="DEPT_NAME"/>
    <result property="deptNo" column="DEPT_NO"/>
    <result property="settlementAmount" column="SETTLEMENT_AMOUNT"/>
    <result property="belongDeptId" column="BELONG_DEPT_ID"/>
    <result property="belongDeptCode" column="BELONG_DEPT_CODE"/>
    <result property="settlementMonth" column="SETTLEMENT_MONTH"/>
    <result property="formType" column="FORM_TYPE"/>
    <result property="remark" column="REMARK"/>
    <result property="salaryMonth" column="SALARY_MONTH"/>
    <result property="moneyFrom" column="MONEY_FROM"/>
    <result property="status" column="STATUS"/>
    <result property="submitTime" column="SUBMIT_TIME"/>
    <result property="deleteFlag" column="DELETE_FLAG"/>
    <result property="auditUser" column="AUDIT_USER"/>
    <result property="auditTime" column="AUDIT_TIME"/>
    <result property="province" column="PROVINCE"/>
    <result property="city" column="CITY"/>
    <result property="town" column="TOWN"/>
    <result property="type" column="TYPE"/>
    <result property="ownNums" column="OWN_NUMS"/>
    <result property="ownMoney" column="OWN_MONEY"/>
    <result property="ownRemark" column="OWN_REMARK"/>
    <result property="haveSalaryFlag" column="HAVE_SALARY_FLAG"/>
    <result property="haveSpecialFlag" column="HAVE_SPECIAL_FLAG"/>
    <result property="haveSalaryRemark" column="HAVE_SALARY_REMARK"/>
    <result property="haveSpecialRemark" column="HAVE_SPECIAL_REMARK"/>
    <result property="submitRemark" column="SUBMIT_REMARK"/>
    <result property="createBy" column="CREATE_BY"/>
    <result property="createName" column="CREATE_NAME"/>
    <result property="createTime" column="CREATE_TIME"/>
    <result property="updateBy" column="UPDATE_BY"/>
    <result property="updateTime" column="UPDATE_TIME"/>
    <result property="unitId" column="UNIT_ID"/>
    <result property="unitName" column="UNIT_NAME"/>
    <result property="sendTime" column="SEND_TIME"/>
    <result property="sendMonth" column="SEND_MONTH"/>
	  <result property="invoiceTitle" column="INVOICE_TITLE"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.DEPT_ID,
                a.DEPT_NAME,
                a.DEPT_NO,
                a.SETTLEMENT_AMOUNT,
                a.BELONG_DEPT_ID,
                a.BELONG_DEPT_CODE,
                a.SETTLEMENT_MONTH,
                a.FORM_TYPE,
                a.REMARK,
                a.SALARY_MONTH,
                a.MONEY_FROM,
                a.STATUS,
                a.SUBMIT_TIME,
                a.DELETE_FLAG,
                a.AUDIT_USER,
                a.AUDIT_TIME,
                a.PROVINCE,
                a.CITY,
                a.TOWN,
                a.TYPE,
                a.OWN_NUMS,
                a.OWN_MONEY,
                a.OWN_REMARK,
                a.HAVE_SALARY_FLAG,
                a.HAVE_SALARY_REMARK,
                a.HAVE_SPECIAL_FLAG,
                a.HAVE_SPECIAL_REMARK,
                a.SUBMIT_REMARK,
                a.CREATE_BY,
                a.CREATE_NAME,
                a.CREATE_TIME,
                a.UPDATE_BY,
                a.UPDATE_TIME,
                a.UNIT_ID,
                a.UNIT_NAME,
                a.UNIT_NO,
                a.SEND_TIME,
                a.SEND_MONTH,
				a.INVOICE_TITLE
    </sql>
    <sql id="tSalaryStandard_where">
        <if test="tSalaryStandard != null">
                    <if test="tSalaryStandard.id != null and tSalaryStandard.id.trim() != ''">
                        AND a.ID = #{tSalaryStandard.id}
                    </if>
                    <if test="tSalaryStandard.deptId != null and tSalaryStandard.deptId.trim() != ''">
                        AND a.DEPT_ID = #{tSalaryStandard.deptId}
                    </if>
                    <if test="tSalaryStandard.deptName != null and tSalaryStandard.deptName.trim() != ''">
                        AND a.DEPT_NAME = #{tSalaryStandard.deptName}
                    </if>
                    <if test="tSalaryStandard.deptNo != null and tSalaryStandard.deptNo.trim() != ''">
                        AND a.DEPT_NO = #{tSalaryStandard.deptNo}
                    </if>
                    <if test="tSalaryStandard.settlementAmount != null">
                        AND a.SETTLEMENT_AMOUNT = #{tSalaryStandard.settlementAmount}
                    </if>
                    <if test="tSalaryStandard.belongDeptId != null and tSalaryStandard.belongDeptId.trim() != ''">
                        AND a.BELONG_DEPT_ID = #{tSalaryStandard.belongDeptId}
                    </if>
                    <if test="tSalaryStandard.belongDeptCode != null and tSalaryStandard.belongDeptCode.trim() != ''">
                        AND a.BELONG_DEPT_CODE = #{tSalaryStandard.belongDeptCode}
                    </if>
                    <if test="tSalaryStandard.settlementMonth != null and tSalaryStandard.settlementMonth.trim() != ''">
                        AND a.SETTLEMENT_MONTH = #{tSalaryStandard.settlementMonth}
                    </if>
                    <if test="tSalaryStandard.formType != null and tSalaryStandard.formType.trim() != ''">
                        AND a.FORM_TYPE = #{tSalaryStandard.formType}
                    </if>
                    <if test="tSalaryStandard.remark != null and tSalaryStandard.remark.trim() != ''">
                        AND a.REMARK = #{tSalaryStandard.remark}
                    </if>
                    <if test="tSalaryStandard.salaryMonth != null and tSalaryStandard.salaryMonth.trim() != ''">
                        AND a.SALARY_MONTH = #{tSalaryStandard.salaryMonth}
                    </if>
                    <if test="tSalaryStandard.moneyFrom != null">
                        AND a.MONEY_FROM = #{tSalaryStandard.moneyFrom}
                    </if>
                    <if test="tSalaryStandard.status != null">
                        AND a.STATUS = #{tSalaryStandard.status}
                    </if>
                    <if test="tSalaryStandard.submitTime != null">
                        AND a.SUBMIT_TIME = #{tSalaryStandard.submitTime}
                    </if>
                    <if test="tSalaryStandard.deleteFlag != null">
                        AND a.DELETE_FLAG = #{tSalaryStandard.deleteFlag}
                    </if>
                    <if test="tSalaryStandard.auditUser != null and tSalaryStandard.auditUser.trim() != ''">
                        AND a.AUDIT_USER = #{tSalaryStandard.auditUser}
                    </if>
                    <if test="tSalaryStandard.auditTime != null">
                        AND a.AUDIT_TIME = #{tSalaryStandard.auditTime}
                    </if>
                    <if test="tSalaryStandard.province != null">
                        AND a.PROVINCE = #{tSalaryStandard.province}
                    </if>
                    <if test="tSalaryStandard.city != null">
                        AND a.CITY = #{tSalaryStandard.city}
                    </if>
                    <if test="tSalaryStandard.town != null">
                        AND a.TOWN = #{tSalaryStandard.town}
                    </if>
                    <if test="tSalaryStandard.type != null">
                        AND a.TYPE = #{tSalaryStandard.type}
                    </if>
                    <if test="tSalaryStandard.ownNums != null">
                        AND a.OWN_NUMS = #{tSalaryStandard.ownNums}
                    </if>
                    <if test="tSalaryStandard.ownMoney != null">
                        AND a.OWN_MONEY = #{tSalaryStandard.ownMoney}
                    </if>
                    <if test="tSalaryStandard.ownRemark != null and tSalaryStandard.ownRemark.trim() != ''">
                        AND a.OWN_REMARK = #{tSalaryStandard.ownRemark}
                    </if>
                    <if test="tSalaryStandard.submitRemark != null and tSalaryStandard.submitRemark.trim() != ''">
                        AND a.SUBMIT_REMARK = #{tSalaryStandard.submitRemark}
                    </if>
                    <if test="tSalaryStandard.createBy != null and tSalaryStandard.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tSalaryStandard.createBy}
                    </if>
                    <if test="tSalaryStandard.createName != null and tSalaryStandard.createName.trim() != ''">
                        AND a.CREATE_NAME = #{tSalaryStandard.createName}
                    </if>
                    <if test="tSalaryStandard.createTime != null">
                        AND a.CREATE_TIME = #{tSalaryStandard.createTime}
                    </if>
                    <if test="tSalaryStandard.updateBy != null and tSalaryStandard.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{tSalaryStandard.updateBy}
                    </if>
                    <if test="tSalaryStandard.updateTime != null">
                        AND a.UPDATE_TIME = #{tSalaryStandard.updateTime}
                    </if>
                    <if test="tSalaryStandard.unitId != null and tSalaryStandard.unitId.trim() != ''">
                        AND a.UNIT_ID = #{tSalaryStandard.unitId}
                    </if>
                    <if test="tSalaryStandard.unitName != null and tSalaryStandard.unitName.trim() != ''">
                        AND a.UNIT_NAME = #{tSalaryStandard.unitName}
                    </if>
                    <if test="tSalaryStandard.unitNo != null and tSalaryStandard.unitNo.trim() != ''">
                        AND a.UNIT_NO = #{tSalaryStandard.unitNo}
                    </if>
					<if test="tSalaryStandard.sendMonth != null and tSalaryStandard.sendMonth.trim() != ''">
						AND a.SEND_MONTH = #{tSalaryStandard.sendMonth}
					</if>
        </if>
    </sql>
    <!--tSalaryStandard简单分页查询-->
    <select id="getTSalaryStandardPage" resultMap="tSalaryStandardMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_salary_standard a
        <where>
            1=1
            <include refid="tSalaryStandard_where"/>
        </where>
    </select>
	<!--tSalaryStandard简单分页查询-->
	<select id="getTSalaryStandardAuditPage" resultMap="tSalaryStandardMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_salary_standard a
		<where>
			1=1
			<include refid="where_page"/>
		</where>
		order by a.CREATE_TIME desc
	</select>
	<resultMap id="salaryStandardExportMap" type="com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardExportVo">
		<result property="status" column="STATUS"/>
		<result property="sendMonth" column="SEND_MONTH"/>
		<result property="deptName" column="DEPT_NAME"/>
		<result property="deptNo" column="DEPT_NO"/>
		<result property="settlementAmount" column="SETTLEMENT_AMOUNT"/>
		<result property="invoiceTitle" column="INVOICE_TITLE"/>
		<result property="createName" column="CREATE_NAME"/>
		<result property="salaryMonth" column="SALARY_MONTH"/>
		<result property="formType" column="FORM_TYPE"/>
		<result property="createTime" column="CREATE_TIME"/>
	</resultMap>
	<!--tSalaryStandard简单分页查询-->
	<select id="getSalaryStandardExport" resultMap="salaryStandardExportMap" parameterType="com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryStandardSearchVo">
		SELECT
		a.STATUS,
		a.SEND_MONTH,
		a.DEPT_NAME,
		a.DEPT_NO,
		a.SETTLEMENT_AMOUNT,
		a.ID,
		a.DEPT_ID,
		a.BELONG_DEPT_ID,
		a.BELONG_DEPT_CODE,
		a.SETTLEMENT_MONTH,
		a.INVOICE_TITLE,
		a.CREATE_NAME,
		a.SALARY_MONTH,
		a.FORM_TYPE,
		a.CREATE_TIME
		FROM t_salary_standard a
		<where>
			1=1
			<include refid="where_export"/>
			<if test="searchVo != null">
				<if test="searchVo.limitStart != null">
					limit #{searchVo.limitStart},#{searchVo.limitEnd}
				</if>
			</if>
		</where>
	</select>
	<!--tSalaryStandard简单分页查询-->
	<select id="getSalaryStandardExportCount"  resultType="java.lang.Integer">
		SELECT
		count(1)
		FROM t_salary_standard a
		<where>
			1=1
			<include refid="where_export"/>
		</where>
	</select>
	<sql id="where_page">
		<if test="tSalaryStandard != null">
			<if test="tSalaryStandard.deptName != null and tSalaryStandard.deptName.trim() != ''">
				AND a.DEPT_NAME like concat(#{'%',#{tSalaryStandard.deptName},'%')
			</if>
			<if test="tSalaryStandard.deptNo != null and tSalaryStandard.deptNo.trim() != ''">
				AND a.DEPT_NO = #{tSalaryStandard.deptNo}
			</if>
			<if test="tSalaryStandard.salaryMonth != null and tSalaryStandard.salaryMonth.trim() != ''">
				AND a.SALARY_MONTH = #{tSalaryStandard.salaryMonth}
			</if>
			<if test="tSalaryStandard.status == null">
				AND (a.STATUS = 1 OR a.STATUS = 2 OR a.STATUS = 5)
			</if>
			<if test="tSalaryStandard.status != null">
				AND a.STATUS = #{tSalaryStandard.status}
			</if>
		</if>
	</sql>
	<sql id="where_export">
		<if test="searchVo != null">
			<if test="searchVo.deptName != null and searchVo.deptName.trim() != ''">
				AND a.DEPT_NAME like concat(#{'%',#{searchVo.deptName},'%')
			</if>
			<if test="searchVo.deptNo != null and searchVo.deptNo.trim() != ''">
				AND a.DEPT_NO = #{searchVo.deptNo}
			</if>
			<if test="searchVo.salaryMonth != null and searchVo.salaryMonth.trim() != ''">
				AND a.SALARY_MONTH = #{searchVo.salaryMonth}
			</if>
			<if test="searchVo.status == null">
				AND (a.STATUS = 1 OR a.STATUS = 2 OR a.STATUS = 5)
			</if>
			<if test="searchVo.status != null">
				AND a.STATUS = #{searchVo.status}
			</if>
		</if>
	</sql>
</mapper>