<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.AssetlogMapper">

    <resultMap type="com.ruoyi.system.domain.Assetlog" id="AssetlogMap">
        <result property="id" column="Id" jdbcType="INTEGER"/>
        <result property="batchid" column="BatchId" jdbcType="INTEGER"/>
        <result property="codeid" column="CodeId" jdbcType="INTEGER"/>
        <result property="created" column="Created" jdbcType="TIMESTAMP"/>
        <result property="username" column="UserName" jdbcType="VARCHAR"/>
        <result property="userid" column="UserId" jdbcType="INTEGER"/>
        <result property="name" column="Name" jdbcType="VARCHAR"/>
        <result property="assetno" column="AssetNo" jdbcType="VARCHAR"/>
        <result property="mainassetno" column="MainAssetNo" jdbcType="VARCHAR"/>
        <result property="assettype" column="AssetType" jdbcType="VARCHAR"/>
        <result property="assettypeid" column="AssetTypeId" jdbcType="INTEGER"/>
        <result property="size" column="Size" jdbcType="VARCHAR"/>
        <result property="model" column="Model" jdbcType="VARCHAR"/>
        <result property="brand" column="Brand" jdbcType="VARCHAR"/>
        <result property="buyed" column="Buyed" jdbcType="TIMESTAMP"/>
        <result property="madeat" column="MadeAt" jdbcType="TIMESTAMP"/>
        <result property="assetunitid" column="AssetUnitId" jdbcType="INTEGER"/>
        <result property="assetunit" column="AssetUnit" jdbcType="VARCHAR"/>
        <result property="quantity" column="Quantity" jdbcType="INTEGER"/>
        <result property="unitprice" column="UnitPrice" jdbcType="NUMERIC"/>
        <result property="totalprice" column="TotalPrice" jdbcType="NUMERIC"/>
        <result property="company" column="Company" jdbcType="VARCHAR"/>
        <result property="companyid" column="CompanyId" jdbcType="INTEGER"/>
        <result property="department" column="Department" jdbcType="VARCHAR"/>
        <result property="departmentid" column="DepartmentId" jdbcType="INTEGER"/>
        <result property="savecompany" column="SaveCompany" jdbcType="VARCHAR"/>
        <result property="savecompanyid" column="SaveCompanyId" jdbcType="INTEGER"/>
        <result property="savedepartment" column="SaveDepartment" jdbcType="VARCHAR"/>
        <result property="savedepartmentid" column="SaveDepartmentId" jdbcType="INTEGER"/>
        <result property="location" column="Location" jdbcType="VARCHAR"/>
        <result property="locationid" column="LocationId" jdbcType="INTEGER"/>
        <result property="used" column="Used" jdbcType="VARCHAR"/>
        <result property="usedid" column="UsedId" jdbcType="INTEGER"/>
        <result property="duty" column="Duty" jdbcType="VARCHAR"/>
        <result property="dutyid" column="DutyId" jdbcType="INTEGER"/>
        <result property="assetstate" column="AssetState" jdbcType="VARCHAR"/>
        <result property="assetstateid" column="AssetStateId" jdbcType="INTEGER"/>
        <result property="assetsource" column="AssetSource" jdbcType="VARCHAR"/>
        <result property="assetsourceid" column="AssetSourceId" jdbcType="INTEGER"/>
        <result property="postingdate" column="PostingDate" jdbcType="TIMESTAMP"/>
        <result property="predictyear" column="PredictYear" jdbcType="INTEGER"/>
        <result property="discount" column="Discount" jdbcType="VARCHAR"/>
        <result property="serialnumber" column="SerialNumber" jdbcType="VARCHAR"/>
        <result property="ischecked" column="IsChecked" jdbcType="VARCHAR"/>
        <result property="financeno" column="FinanceNo" jdbcType="VARCHAR"/>
        <result property="financetype" column="FinanceType" jdbcType="VARCHAR"/>
        <result property="originalno" column="OriginalNo" jdbcType="VARCHAR"/>
        <result property="factoryno" column="FactoryNo" jdbcType="VARCHAR"/>
        <result property="memo" column="Memo" jdbcType="VARCHAR"/>
        <result property="repairat" column="RepairAt" jdbcType="TIMESTAMP"/>
        <result property="takestock" column="TakeStock" jdbcType="VARCHAR"/>
        <result property="gone" column="Gone" jdbcType="INTEGER"/>
        <result property="state" column="state" jdbcType="INTEGER"/>
        <result property="scrapat" column="ScrapAt" jdbcType="TIMESTAMP"/>
        <result property="scrapway" column="ScrapWay" jdbcType="VARCHAR"/>
        <result property="photo" column="Photo" jdbcType="VARCHAR"/>
        <result property="refuse" column="Refuse" jdbcType="VARCHAR"/>
        <result property="formula" column="Formula" jdbcType="INTEGER"/>
        <result property="guid" column="Guid" jdbcType="INTEGER"/>
        <result property="copyid" column="CopyId" jdbcType="INTEGER"/>
        <result property="parentid" column="ParentId" jdbcType="INTEGER"/>
        <result property="jiti" column="Jiti" jdbcType="TIMESTAMP"/>
        <result property="para1" column="Para1" jdbcType="VARCHAR"/>
        <result property="para2" column="Para2" jdbcType="VARCHAR"/>
        <result property="para3" column="Para3" jdbcType="VARCHAR"/>
        <result property="para4" column="Para4" jdbcType="VARCHAR"/>
        <result property="para5" column="Para5" jdbcType="VARCHAR"/>
        <result property="para6" column="Para6" jdbcType="VARCHAR"/>
        <result property="para7" column="Para7" jdbcType="VARCHAR"/>
        <result property="para8" column="Para8" jdbcType="VARCHAR"/>
        <result property="approvalid" column="ApprovalId" jdbcType="INTEGER"/>
        <result property="receive" column="Receive" jdbcType="INTEGER"/>
        <result property="prevDutyid" column="Prev_DutyId" jdbcType="INTEGER"/>
        <result property="prevDuty" column="Prev_Duty" jdbcType="VARCHAR"/>
        <result property="prevCompany" column="Prev_Company" jdbcType="VARCHAR"/>
        <result property="prevDepartment" column="Prev_Department" jdbcType="VARCHAR"/>
        <result property="store" column="Store" jdbcType="VARCHAR"/>
        <result property="beforedepreciation" column="BeforeDepreciation" jdbcType="NUMERIC"/>
        <result property="beforemonth" column="BeforeMonth" jdbcType="INTEGER"/>
        <result property="newplace" column="NewPlace" jdbcType="VARCHAR"/>
        <result property="tax" column="Tax" jdbcType="INTEGER"/>
        <result property="usefor" column="UseFor" jdbcType="VARCHAR"/>
        <result property="telPhone" column="Telefon" jdbcType="VARCHAR"/>
    </resultMap>

    <!--查询单个-->
    <select id="queryById" resultMap="AssetlogMap">
        select a.Id,
               a.BatchId,
               a.CodeId,
               a.Created,
               a.UserName,
               a.UserId,
               a.Name,
               a.AssetNo,
               a.MainAssetNo,
               a.AssetType,
               a.AssetTypeId,
               a.Size,
               a.Model,
               a.Brand,
               a.Buyed,
               a.MadeAt,
               a.AssetUnitId,
               a.AssetUnit,
               a.Quantity,
               a.UnitPrice,
               a.TotalPrice,
               a.Company,
               a.CompanyId,
               a.Department,
               a.DepartmentId,
               a.SaveCompany,
               a.SaveCompanyId,
               a.SaveDepartment,
               a.SaveDepartmentId,
               a.Location,
               a.LocationId,
               a.Used,
               a.UsedId,
               a.Duty,
               a.DutyId,
               a.AssetState,
               a.AssetStateId,
               a.AssetSource,
               a.AssetSourceId,
               a.PostingDate,
               a.PredictYear,
               a.Discount,
               a.SerialNumber,
               a.IsChecked,
               a.FinanceNo,
               a.FinanceType,
               a.OriginalNo,
               a.FactoryNo,
               a.Memo,
               a.RepairAt,
               a.TakeStock,
               a.Gone,
               a.state,
               a.ScrapAt,
               a.ScrapWay,
               a.Photo,
               a.Refuse,
               a.Formula,
               a.Guid,
               a.CopyId,
               a.ParentId,
               a.Jiti,
               a.Para1,
               a.Para2,
               a.Para3,
               a.Para4,
               a.Para5,
               a.Para6,
               a.Para7,
               a.Para8,
               a.ApprovalId,
               a.Receive,
               a.Prev_DutyId,
               a.Prev_Duty,
               a.Prev_Company,
               a.Prev_Department,
               a.Store,
               a.BeforeDepreciation,
               a.BeforeMonth,
               a.NewPlace,
               a.Tax,
               a.UseFor,
               u.Telefon
        from AssetLog a
        left join Users u on a.UserId = u.Id
        where a.Id = #{id}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="AssetlogMap">
        select
        Id,
        BatchId,
        CodeId,
        Created,
        UserName,
        UserId,
        Name,
        AssetNo,
        MainAssetNo,
        AssetType,
        AssetTypeId,
        Size,
        Model,
        Brand,
        Buyed,
        MadeAt,
        AssetUnitId,
        AssetUnit,
        Quantity,
        UnitPrice,
        TotalPrice,
        Company,
        CompanyId,
        Department,
        DepartmentId,
        SaveCompany,
        SaveCompanyId,
        SaveDepartment,
        SaveDepartmentId,
        Location,
        LocationId,
        Used,
        UsedId,
        Duty,
        DutyId,
        AssetState,
        AssetStateId,
        AssetSource,
        AssetSourceId,
        PostingDate,
        PredictYear,
        Discount,
        SerialNumber,
        IsChecked,
        FinanceNo,
        FinanceType,
        OriginalNo,
        FactoryNo,
        Memo,
        RepairAt,
        TakeStock,
        Gone,
        state,
        ScrapAt,
        ScrapWay,
        Photo,
        Refuse,
        Formula,
        Guid,
        CopyId,
        ParentId,
        Jiti,
        Para1,
        Para2,
        Para3,
        Para4,
        Para5,
        Para6,
        Para7,
        Para8,
        ApprovalId,
        Receive,
        Prev_DutyId,
        Prev_Duty,
        Prev_Company,
        Prev_Department,
        Store,
        BeforeDepreciation,
        BeforeMonth,
        NewPlace,
        Tax,
        UseFor

        from AssetLog
        <where>
            <if test="id != null">
                and Id = #{id}
            </if>
            <if test="batchid != null">
                and BatchId = #{batchid}
            </if>
            <if test="codeid != null">
                and CodeId = #{codeid}
            </if>
            <if test="created != null">
                and Created = #{created}
            </if>
            <if test="username != null and username != ''">
                and UserName = #{username}
            </if>
            <if test="userid != null">
                and UserId = #{userid}
            </if>
            <if test="name != null and name != ''">
                and Name = #{name}
            </if>
            <if test="assetno != null and assetno != ''">
                and AssetNo = #{assetno}
            </if>
            <if test="mainassetno != null and mainassetno != ''">
                and MainAssetNo = #{mainassetno}
            </if>
            <if test="assettype != null and assettype != ''">
                and AssetType = #{assettype}
            </if>
            <if test="assettypeid != null">
                and AssetTypeId = #{assettypeid}
            </if>
            <if test="size != null and size != ''">
                and Size = #{size}
            </if>
            <if test="model != null and model != ''">
                and Model = #{model}
            </if>
            <if test="brand != null and brand != ''">
                and Brand = #{brand}
            </if>
            <if test="buyed != null">
                and Buyed = #{buyed}
            </if>
            <if test="madeat != null">
                and MadeAt = #{madeat}
            </if>
            <if test="assetunitid != null">
                and AssetUnitId = #{assetunitid}
            </if>
            <if test="assetunit != null and assetunit != ''">
                and AssetUnit = #{assetunit}
            </if>
            <if test="quantity != null">
                and Quantity = #{quantity}
            </if>
            <if test="unitprice != null">
                and UnitPrice = #{unitprice}
            </if>
            <if test="totalprice != null">
                and TotalPrice = #{totalprice}
            </if>
            <if test="company != null and company != ''">
                and Company = #{company}
            </if>
            <if test="companyid != null">
                and CompanyId = #{companyid}
            </if>
            <if test="department != null and department != ''">
                and Department = #{department}
            </if>
            <if test="departmentid != null">
                and DepartmentId = #{departmentid}
            </if>
            <if test="savecompany != null and savecompany != ''">
                and SaveCompany = #{savecompany}
            </if>
            <if test="savecompanyid != null">
                and SaveCompanyId = #{savecompanyid}
            </if>
            <if test="savedepartment != null and savedepartment != ''">
                and SaveDepartment = #{savedepartment}
            </if>
            <if test="savedepartmentid != null">
                and SaveDepartmentId = #{savedepartmentid}
            </if>
            <if test="location != null and location != ''">
                and Location = #{location}
            </if>
            <if test="locationid != null">
                and LocationId = #{locationid}
            </if>
            <if test="used != null and used != ''">
                and Used = #{used}
            </if>
            <if test="usedid != null">
                and UsedId = #{usedid}
            </if>
            <if test="duty != null and duty != ''">
                and Duty = #{duty}
            </if>
            <if test="dutyid != null">
                and DutyId = #{dutyid}
            </if>
            <if test="assetstate != null and assetstate != ''">
                and AssetState = #{assetstate}
            </if>
            <if test="assetstateid != null">
                and AssetStateId = #{assetstateid}
            </if>
            <if test="assetsource != null and assetsource != ''">
                and AssetSource = #{assetsource}
            </if>
            <if test="assetsourceid != null">
                and AssetSourceId = #{assetsourceid}
            </if>
            <if test="postingdate != null">
                and PostingDate = #{postingdate}
            </if>
            <if test="predictyear != null">
                and PredictYear = #{predictyear}
            </if>
            <if test="discount != null and discount != ''">
                and Discount = #{discount}
            </if>
            <if test="serialnumber != null and serialnumber != ''">
                and SerialNumber = #{serialnumber}
            </if>
            <if test="ischecked != null and ischecked != ''">
                and IsChecked = #{ischecked}
            </if>
            <if test="financeno != null and financeno != ''">
                and FinanceNo = #{financeno}
            </if>
            <if test="financetype != null and financetype != ''">
                and FinanceType = #{financetype}
            </if>
            <if test="originalno != null and originalno != ''">
                and OriginalNo = #{originalno}
            </if>
            <if test="factoryno != null and factoryno != ''">
                and FactoryNo = #{factoryno}
            </if>
            <if test="memo != null and memo != ''">
                and Memo = #{memo}
            </if>
            <if test="repairat != null">
                and RepairAt = #{repairat}
            </if>
            <if test="takestock != null and takestock != ''">
                and TakeStock = #{takestock}
            </if>
            <if test="gone != null">
                and Gone = #{gone}
            </if>
            <if test="state != null">
                and state = #{state}
            </if>
            <if test="scrapat != null">
                and ScrapAt = #{scrapat}
            </if>
            <if test="scrapway != null and scrapway != ''">
                and ScrapWay = #{scrapway}
            </if>
            <if test="photo != null and photo != ''">
                and Photo = #{photo}
            </if>
            <if test="refuse != null and refuse != ''">
                and Refuse = #{refuse}
            </if>
            <if test="formula != null">
                and Formula = #{formula}
            </if>
            <if test="guid != null">
                and Guid = #{guid}
            </if>
            <if test="copyid != null">
                and CopyId = #{copyid}
            </if>
            <if test="parentid != null">
                and ParentId = #{parentid}
            </if>
            <if test="jiti != null">
                and Jiti = #{jiti}
            </if>
            <if test="para1 != null and para1 != ''">
                and Para1 = #{para1}
            </if>
            <if test="para2 != null and para2 != ''">
                and Para2 = #{para2}
            </if>
            <if test="para3 != null and para3 != ''">
                and Para3 = #{para3}
            </if>
            <if test="para4 != null and para4 != ''">
                and Para4 = #{para4}
            </if>
            <if test="para5 != null and para5 != ''">
                and Para5 = #{para5}
            </if>
            <if test="para6 != null and para6 != ''">
                and Para6 = #{para6}
            </if>
            <if test="para7 != null and para7 != ''">
                and Para7 = #{para7}
            </if>
            <if test="para8 != null and para8 != ''">
                and Para8 = #{para8}
            </if>
            <if test="approvalid != null">
                and ApprovalId = #{approvalid}
            </if>
            <if test="receive != null">
                and Receive = #{receive}
            </if>
            <if test="prevDutyid != null">
                and Prev_DutyId = #{prevDutyid}
            </if>
            <if test="prevDuty != null and prevDuty != ''">
                and Prev_Duty = #{prevDuty}
            </if>
            <if test="prevCompany != null and prevCompany != ''">
                and Prev_Company = #{prevCompany}
            </if>
            <if test="prevDepartment != null and prevDepartment != ''">
                and Prev_Department = #{prevDepartment}
            </if>
            <if test="store != null and store != ''">
                and Store = #{store}
            </if>
            <if test="beforedepreciation != null">
                and BeforeDepreciation = #{beforedepreciation}
            </if>
            <if test="beforemonth != null">
                and BeforeMonth = #{beforemonth}
            </if>
            <if test="newplace != null and newplace != ''">
                and NewPlace = #{newplace}
            </if>
            <if test="tax != null">
                and Tax = #{tax}
            </if>
            <if test="usefor != null and usefor != ''">
                and UseFor = #{usefor}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from AssetLog
        <where>
            <if test="id != null">
                and Id = #{id}
            </if>
            <if test="batchid != null">
                and BatchId = #{batchid}
            </if>
            <if test="codeid != null">
                and CodeId = #{codeid}
            </if>
            <if test="created != null">
                and Created = #{created}
            </if>
            <if test="username != null and username != ''">
                and UserName = #{username}
            </if>
            <if test="userid != null">
                and UserId = #{userid}
            </if>
            <if test="name != null and name != ''">
                and Name = #{name}
            </if>
            <if test="assetno != null and assetno != ''">
                and AssetNo = #{assetno}
            </if>
            <if test="mainassetno != null and mainassetno != ''">
                and MainAssetNo = #{mainassetno}
            </if>
            <if test="assettype != null and assettype != ''">
                and AssetType = #{assettype}
            </if>
            <if test="assettypeid != null">
                and AssetTypeId = #{assettypeid}
            </if>
            <if test="size != null and size != ''">
                and Size = #{size}
            </if>
            <if test="model != null and model != ''">
                and Model = #{model}
            </if>
            <if test="brand != null and brand != ''">
                and Brand = #{brand}
            </if>
            <if test="buyed != null">
                and Buyed = #{buyed}
            </if>
            <if test="madeat != null">
                and MadeAt = #{madeat}
            </if>
            <if test="assetunitid != null">
                and AssetUnitId = #{assetunitid}
            </if>
            <if test="assetunit != null and assetunit != ''">
                and AssetUnit = #{assetunit}
            </if>
            <if test="quantity != null">
                and Quantity = #{quantity}
            </if>
            <if test="unitprice != null">
                and UnitPrice = #{unitprice}
            </if>
            <if test="totalprice != null">
                and TotalPrice = #{totalprice}
            </if>
            <if test="company != null and company != ''">
                and Company = #{company}
            </if>
            <if test="companyid != null">
                and CompanyId = #{companyid}
            </if>
            <if test="department != null and department != ''">
                and Department = #{department}
            </if>
            <if test="departmentid != null">
                and DepartmentId = #{departmentid}
            </if>
            <if test="savecompany != null and savecompany != ''">
                and SaveCompany = #{savecompany}
            </if>
            <if test="savecompanyid != null">
                and SaveCompanyId = #{savecompanyid}
            </if>
            <if test="savedepartment != null and savedepartment != ''">
                and SaveDepartment = #{savedepartment}
            </if>
            <if test="savedepartmentid != null">
                and SaveDepartmentId = #{savedepartmentid}
            </if>
            <if test="location != null and location != ''">
                and Location = #{location}
            </if>
            <if test="locationid != null">
                and LocationId = #{locationid}
            </if>
            <if test="used != null and used != ''">
                and Used = #{used}
            </if>
            <if test="usedid != null">
                and UsedId = #{usedid}
            </if>
            <if test="duty != null and duty != ''">
                and Duty = #{duty}
            </if>
            <if test="dutyid != null">
                and DutyId = #{dutyid}
            </if>
            <if test="assetstate != null and assetstate != ''">
                and AssetState = #{assetstate}
            </if>
            <if test="assetstateid != null">
                and AssetStateId = #{assetstateid}
            </if>
            <if test="assetsource != null and assetsource != ''">
                and AssetSource = #{assetsource}
            </if>
            <if test="assetsourceid != null">
                and AssetSourceId = #{assetsourceid}
            </if>
            <if test="postingdate != null">
                and PostingDate = #{postingdate}
            </if>
            <if test="predictyear != null">
                and PredictYear = #{predictyear}
            </if>
            <if test="discount != null and discount != ''">
                and Discount = #{discount}
            </if>
            <if test="serialnumber != null and serialnumber != ''">
                and SerialNumber = #{serialnumber}
            </if>
            <if test="ischecked != null and ischecked != ''">
                and IsChecked = #{ischecked}
            </if>
            <if test="financeno != null and financeno != ''">
                and FinanceNo = #{financeno}
            </if>
            <if test="financetype != null and financetype != ''">
                and FinanceType = #{financetype}
            </if>
            <if test="originalno != null and originalno != ''">
                and OriginalNo = #{originalno}
            </if>
            <if test="factoryno != null and factoryno != ''">
                and FactoryNo = #{factoryno}
            </if>
            <if test="memo != null and memo != ''">
                and Memo = #{memo}
            </if>
            <if test="repairat != null">
                and RepairAt = #{repairat}
            </if>
            <if test="takestock != null and takestock != ''">
                and TakeStock = #{takestock}
            </if>
            <if test="gone != null">
                and Gone = #{gone}
            </if>
            <if test="state != null">
                and state = #{state}
            </if>
            <if test="scrapat != null">
                and ScrapAt = #{scrapat}
            </if>
            <if test="scrapway != null and scrapway != ''">
                and ScrapWay = #{scrapway}
            </if>
            <if test="photo != null and photo != ''">
                and Photo = #{photo}
            </if>
            <if test="refuse != null and refuse != ''">
                and Refuse = #{refuse}
            </if>
            <if test="formula != null">
                and Formula = #{formula}
            </if>
            <if test="guid != null">
                and Guid = #{guid}
            </if>
            <if test="copyid != null">
                and CopyId = #{copyid}
            </if>
            <if test="parentid != null">
                and ParentId = #{parentid}
            </if>
            <if test="jiti != null">
                and Jiti = #{jiti}
            </if>
            <if test="para1 != null and para1 != ''">
                and Para1 = #{para1}
            </if>
            <if test="para2 != null and para2 != ''">
                and Para2 = #{para2}
            </if>
            <if test="para3 != null and para3 != ''">
                and Para3 = #{para3}
            </if>
            <if test="para4 != null and para4 != ''">
                and Para4 = #{para4}
            </if>
            <if test="para5 != null and para5 != ''">
                and Para5 = #{para5}
            </if>
            <if test="para6 != null and para6 != ''">
                and Para6 = #{para6}
            </if>
            <if test="para7 != null and para7 != ''">
                and Para7 = #{para7}
            </if>
            <if test="para8 != null and para8 != ''">
                and Para8 = #{para8}
            </if>
            <if test="approvalid != null">
                and ApprovalId = #{approvalid}
            </if>
            <if test="receive != null">
                and Receive = #{receive}
            </if>
            <if test="prevDutyid != null">
                and Prev_DutyId = #{prevDutyid}
            </if>
            <if test="prevDuty != null and prevDuty != ''">
                and Prev_Duty = #{prevDuty}
            </if>
            <if test="prevCompany != null and prevCompany != ''">
                and Prev_Company = #{prevCompany}
            </if>
            <if test="prevDepartment != null and prevDepartment != ''">
                and Prev_Department = #{prevDepartment}
            </if>
            <if test="store != null and store != ''">
                and Store = #{store}
            </if>
            <if test="beforedepreciation != null">
                and BeforeDepreciation = #{beforedepreciation}
            </if>
            <if test="beforemonth != null">
                and BeforeMonth = #{beforemonth}
            </if>
            <if test="newplace != null and newplace != ''">
                and NewPlace = #{newplace}
            </if>
            <if test="tax != null">
                and Tax = #{tax}
            </if>
            <if test="usefor != null and usefor != ''">
                and UseFor = #{usefor}
            </if>
        </where>
    </select>
    <select id="list" parameterType="assetVo" resultMap="AssetlogMap">
        select Id,
               BatchId,
               CodeId,
               Created,
               UserName,
               UserId,
               Name,
               AssetNo,
               MainAssetNo,
               AssetType,
               AssetTypeId,
               Size,
               Model,
               Brand,
               Buyed,
               MadeAt,
               AssetUnitId,
               AssetUnit,
               Quantity,
               UnitPrice,
               TotalPrice,
               Company,
               CompanyId,
               Department,
               DepartmentId,
               SaveCompany,
               SaveCompanyId,
               SaveDepartment,
               SaveDepartmentId,
               Location,
               LocationId,
               Used,
               UsedId,
               Duty,
               DutyId,
               AssetState,
               AssetStateId,
               AssetSource,
               AssetSourceId,
               PostingDate,
               PredictYear,
               Discount,
               SerialNumber,
               IsChecked,
               FinanceNo,
               FinanceType,
               OriginalNo,
               FactoryNo,
               Memo,
               RepairAt,
               TakeStock,
               Gone,
               state,
               ScrapAt,
               ScrapWay,
               Photo,
               Refuse,
               Formula,
               Guid,
               CopyId,
               ParentId,
               Jiti,
               Para1,
               Para2,
               Para3,
               Para4,
               Para5,
               Para6,
               Para7,
               Para8,
               ApprovalId,
               Receive,
               Prev_DutyId,
               Prev_Duty,
               Prev_Company,
               Prev_Department,
               Store,
               BeforeDepreciation,
               BeforeMonth,
               NewPlace,
               Tax,
               UseFor
        from AssetLog
        <where>
            AND CodeId = #{assetVo.codeId}
            AND state !=3
            AND  Guid = 0
            AND  Gone = 0
            AND DutyId IN
            <foreach item="item" index="index" collection="item" open="(" separator="," close=")">
                #{item}
            </foreach>
            AND SaveDepartmentId = #{assetVo.departmentId}
            AND SaveCompanyId = #{assetVo.companyId}
            <if test="assetVo.assetName != null and assetVo.assetName != ''">
               AND Name LIKE '%'+#{assetVo.assetName}+'%'
            </if>
            <if test="assetVo.assetType != null and assetVo.assetType != ''">
                AND AssetType = #{assetVo.assetType}
            </if>
        </where>

    </select>

    <select id="newList" parameterType="assetVo" resultMap="AssetlogMap">
        select *
        from AssetLog
        <where>
            AND AssetType IS NOT NULL
            AND state != 3
            AND Guid = 0
            AND Gone = 0
            <if test="assetVo.departmentId != null and assetVo.departmentId != 0">
                AND (DepartmentId = #{assetVo.departmentId} OR SaveDepartmentId = #{assetVo.departmentId})
            </if>
            <if test="assetVo.assetName != null and assetVo.assetName != ''">
                AND Name LIKE '%'+#{assetVo.assetName}+'%'
            </if>
            <if test="assetVo.assetType != null and assetVo.assetType != ''">
                AND AssetType = #{assetVo.assetType}
            </if>
        </where>
    </select>

    <select id="getAssetType" resultType="java.util.Map">
        SELECT AssetType, COUNT(DISTINCT Name) AS num
        FROM AssetLog
        WHERE AssetType IS NOT NULL AND state != 3 AND Guid = 0 AND Gone = 0
        <if test="departmentId != null and departmentId != 0">
            AND (DepartmentId = #{departmentId} OR SaveDepartmentId = #{departmentId})
        </if>
        GROUP BY AssetType
    </select>

    <select id="sumAssetType" resultType="java.util.Map">
        SELECT AssetType, SUM(Quantity) AS num
        FROM AssetLog
        WHERE AssetType IS NOT NULL AND state != 3 AND Guid = 0 AND Gone = 0
        <if test="departmentId != null and departmentId != 0">
            AND (DepartmentId = #{departmentId} OR SaveDepartmentId = #{departmentId})
        </if>
        GROUP BY AssetType
    </select>

    <select id="getAssetSource" resultType="java.util.Map">
        SELECT AssetSource, SUM(Quantity) AS num
        FROM AssetLog
        WHERE AssetType IS NOT NULL AND state != 3 AND Guid = 0 AND Gone = 0
        <if test="departmentId != null and departmentId != 0">
            AND (DepartmentId = #{departmentId} OR SaveDepartmentId = #{departmentId})
        </if>
        GROUP BY AssetSource
    </select>

    <select id="getAssetBorrow" resultType="java.util.Map">
        SELECT ba.AssetId, ba.State, ba.InCompany, ba.InDepartment, ba.InKeeper, b.*, m.Department
        FROM BorrowAsset ba
        LEFT JOIN Borrow b ON ba.BorrowId = b.Id
        LEFT JOIN Member m ON b.BorrowUserId = m.Id
        WHERE AssetId = #{assetId}
        ORDER BY b.BorrowAt DESC
    </select>

    <select id="getAssetGiveBack" resultType="java.util.Map">
        SELECT gba.AssetId, gba.InDepartment, gba.InKeeper, gba.InCompany, gb.*, m.Department
        FROM GiveBackAsset gba
        LEFT JOIN GiveBack gb ON gba.GiveBackId = gb.Id
        LEFT JOIN Member m ON gb.BackUserId = m.Id
        WHERE AssetId = #{assetId}
        ORDER BY gb.BackAt DESC
    </select>

    <select id="getAssetRepair" resultType="java.util.Map">
        SELECT ra.AssetId, ra.Status, ra.InKeeper, ra.InCompany, ra.InDepartment, r.*
        FROM RepairAsset ra
        LEFT JOIN Repair r ON ra.RepairId = r.Id
        WHERE ra.AssetId = #{assetId}
        ORDER BY r.RepairAt DESC
    </select>

    <select id="getAssetScrap" resultType="java.util.Map">
        SELECT sa.AssetId, sa.InKeeper, sa.InCompany, sa.InDepartment, s.*
        FROM ScrapAsset sa
        LEFT JOIN Scrap s ON sa.ScrapId = s.Id
        WHERE sa.AssetId = #{assetId}
        ORDER BY s.ScrapAt DESC
    </select>

    <select id="mobileLogin" resultType="java.util.Map">
        SELECT * FROM Users
        WHERE Account = #{username} AND Password = #{password}
    </select>

</mapper>

