<?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.jeethink.tjfx.mapper.TjfxMapper">

  <!--  <resultMap id="flowMap" type="ArchivesFlow">
        <id property="flowId" column="flow_id"/>
        <result property="flowType" column="flow_type"/>
        <result property="archivesId" column="archives_id"/>
        <result property="nowStatus" column="now_status"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>-->

    <select id="selectReceiveCount" resultType="java.util.HashMap">
        SELECT * FROM (
           ( SELECT count(1) total FROM archives_master WHERE now_status = '10' and deleted = '0'
           ) AS total,
          ( SELECT count(1) month FROM archives_master
          WHERE now_status = '10' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-%m') and deleted = '0'
          )AS month ,
          ( SELECT count(1) year FROM archives_master
          WHERE now_status = '10'
          AND date_format(update_time,'%Y')=date_format(now(),'%Y') and deleted = '0'
          )AS year
          )
    </select>
    <select id="selectManageCount" resultType="java.util.HashMap">
        SELECT * FROM (
           ( SELECT count(1) total FROM archives_master WHERE now_status = '99' and deleted = '0'
           ) AS total,
              ( SELECT count(1) month FROM archives_master
              WHERE now_status = '99' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-%m') and deleted = '0'
              )AS month ,
              ( SELECT count(1) year FROM archives_master
              WHERE now_status = '99'
              AND date_format(update_time,'%Y')=date_format(now(),'%Y') and deleted = '0'
              )AS year
              )
    </select>
    <select id="selectUseCount" resultType="java.util.HashMap">
        SELECT * FROM (
           ( SELECT count(1) borrow FROM archives_borrow WHERE 1=1
           ) AS borrow,
          ( SELECT count(1) isReturn FROM archives_borrow WHERE borrow_status = '12'
          )AS isReturn ,
          ( SELECT count(1) notReturn FROM archives_borrow WHERE borrow_status != '12'
          )AS notReturn
          )
    </select>
    <select id="selectSaveCount" resultType="java.util.HashMap">
        SELECT * FROM (
           ( SELECT count(1) yj FROM archives_master WHERE 1=1 and deleted = '0'
           ) AS yj,
          ( SELECT count(1) rk FROM archives_master WHERE now_status = '10' and deleted = '0'
          )AS rk ,
          ( SELECT count(1) ck FROM archives_master WHERE now_status = '99' and deleted = '0'
          )AS ck
          )
    </select>
    <select id="selectReceiveList" resultType="java.util.HashMap">
        SELECT am.archives_id archivesId,am.name,DATE_FORMAT(am.update_time,'%Y-%m-%d %H:%i:%s') time,su.nick_name userName
        FROM archives_master am
        left JOIN sys_user su on su.user_id = am.user_id
        WHERE 1=1 and am.deleted = '0' and am.now_status = '10'
    </select>
    <select id="selectBorrowList" resultType="java.util.HashMap">
        SELECT am.archives_id archivesId,am.name,ab.borrow_id borrowId, DATE_FORMAT(ab.create_time,'%Y-%m-%d %H:%i:%s') time,su.nick_name userName
        FROM archives_borrow ab
        left JOIN archives_master am on am.archives_id = ab.archives_id
        left JOIN sys_user su on su.user_name = ab.create_by
        WHERE 1=1 and am.deleted = '0'
    </select>
    <select id="selectReturnList" resultType="java.util.HashMap">
        SELECT am.archives_id archivesId,am.name,ab.borrow_id borrowId, DATE_FORMAT(ab.real_reback_time,'%Y-%m-%d %H:%i:%s') time,su.nick_name userName
        FROM archives_borrow ab
        left JOIN archives_master am on am.archives_id = ab.archives_id
        left JOIN sys_user su on su.user_name = ab.create_by
        WHERE 1=1 and am.deleted = '0' and ab.borrow_status = '12'
    </select>
    <select id="selectPieChartList" resultType="java.util.HashMap">
        SELECT COUNT(*) value,
            CASE
            WHEN type = 0 THEN '人事'
            WHEN type = 1 THEN '健康'
            END AS name
        FROM archives_master where deleted ='0' GROUP BY type
    </select>
    <select id="selectRKListByMonth" resultType="java.util.HashMap">
        SELECT * FROM (
           ( SELECT count(1) January FROM archives_master
             WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-01')
           )AS January ,
          ( SELECT count(1) February  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-02')
          )AS February ,
          ( SELECT count(1) March  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-03')
          )AS March ,
          ( SELECT count(1) April  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-04')
          )AS April ,
          ( SELECT count(1) May  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-05')
          )AS May ,
          ( SELECT count(1) June  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-06')
          )AS June ,
          ( SELECT count(1) July  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-07')
          )AS July ,
          ( SELECT count(1) August  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-08')
          )AS August ,
          ( SELECT count(1) September  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-09')
          )AS September ,
          ( SELECT count(1) October  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-10')
          )AS October ,
          ( SELECT count(1) November  FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-11')
          )AS November ,
          ( SELECT count(1) December FROM archives_master
          WHERE now_status = '10' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-12')
          )AS December
        )
    </select>
    <select id="selectJyPieChartList" resultType="java.util.HashMap">
        SELECT
            IFNULL(count(*),0) value,
            CASE
                WHEN type = 0 THEN '人事'
                WHEN type = 1 THEN '健康'
                END AS name
        FROM archives_borrow ab
        LEFT JOIN archives_master am ON am.archives_id = ab.archives_id
        WHERE
            1 = 1
            AND am.deleted = '0'
        GROUP BY am.type
    </select>
    <select id="selectTJListByMonth" resultType="java.util.HashMap">
        SELECT * FROM (
           ( SELECT count(1) January FROM archives_file af
            LEFT JOIN archives_master am on am.archives_id = af.archives_id
             WHERE  am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-01')
           )AS January ,
          ( SELECT count(1) February  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-02')
          )AS February ,
          ( SELECT count(1) March  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-03')
          )AS March ,
          ( SELECT count(1) April  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-04')
          )AS April ,
          ( SELECT count(1) May  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-05')
          )AS May ,
          ( SELECT count(1) June  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-06')
          )AS June ,
          ( SELECT count(1) July  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-07')
          )AS July ,
          ( SELECT count(1) August  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-08')
          )AS August ,
          ( SELECT count(1) September  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-09')
          )AS September ,
          ( SELECT count(1) October  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-10')
          )AS October ,
          ( SELECT count(1) November  FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-11')
          )AS November ,
          ( SELECT count(1) December FROM archives_file af
          LEFT JOIN archives_master am on am.archives_id = af.archives_id
          WHERE am.now_status = '10' AND am.type='1' AND am.deleted='0' AND date_format(af.check_date,'%Y-%m')=date_format(now(),'%Y-12')
          )AS December
        )
    </select>
    <select id="selectTJListByYear" resultType="java.util.HashMap">
        SELECT
            count(af.archives_file_id) value, af.jk_file_date year
        FROM archives_file af
        WHERE
            1=1
            AND af.jk_file_date is not NULL
            AND af.jk_file_date &lt;&gt; ''
          and af.archives_id in (SELECT archives_id FROM archives_master WHERE deleted = '0' AND type = '1')
        GROUP BY af.jk_file_date
    </select>
    <select id="selectRsListByMonth" resultType="java.util.HashMap">
        SELECT * FROM (
           ( SELECT count(1) January FROM archives_master
             WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-01')
           )AS January ,
              ( SELECT count(1) February  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-02')
              )AS February ,
              ( SELECT count(1) March  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-03')
              )AS March ,
              ( SELECT count(1) April  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-04')
              )AS April ,
              ( SELECT count(1) May  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-05')
              )AS May ,
              ( SELECT count(1) June  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-06')
              )AS June ,
              ( SELECT count(1) July  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-07')
              )AS July ,
              ( SELECT count(1) August  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-08')
              )AS August ,
              ( SELECT count(1) September  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-09')
              )AS September ,
              ( SELECT count(1) October  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-10')
              )AS October ,
              ( SELECT count(1) November  FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-11')
              )AS November ,
              ( SELECT count(1) December FROM archives_master
              WHERE now_status = '10' AND type='0' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-12')
              )AS December
              )
    </select>
    <select id="selectJkListByMonth" resultType="java.util.HashMap">
        SELECT * FROM (
           ( SELECT count(1) January FROM archives_master
             WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-01')
           )AS January ,
              ( SELECT count(1) February  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-02')
              )AS February ,
              ( SELECT count(1) March  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-03')
              )AS March ,
              ( SELECT count(1) April  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-04')
              )AS April ,
              ( SELECT count(1) May  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-05')
              )AS May ,
              ( SELECT count(1) June  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-06')
              )AS June ,
              ( SELECT count(1) July  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-07')
              )AS July ,
              ( SELECT count(1) August  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-08')
              )AS August ,
              ( SELECT count(1) September  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-09')
              )AS September ,
              ( SELECT count(1) October  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-10')
              )AS October ,
              ( SELECT count(1) November  FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-11')
              )AS November ,
              ( SELECT count(1) December FROM archives_master
              WHERE now_status = '10' AND type='1' AND deleted='0' AND date_format(update_time,'%Y-%m')=date_format(now(),'%Y-12')
              )AS December
              )
    </select>
    <select id="selectRsJyListByMonth" resultType="java.util.HashMap">
        SELECT * FROM (
            ( SELECT count(1) January FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-01')
            )AS January ,
            ( SELECT count(1) February FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-02')
            )AS February ,
            ( SELECT count(1) March FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-03')
            )AS March ,
            ( SELECT count(1) April FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-04')
            )AS April ,
            ( SELECT count(1) May  FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-05')
            )AS May ,
            ( SELECT count(1) June FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-06')
            )AS June ,
            ( SELECT count(1) July FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-07')
            )AS July ,
            ( SELECT count(1) August FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-08')
            )AS August ,
            ( SELECT count(1) September FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-09')
            )AS September ,
            ( SELECT count(1) October FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-10')
            )AS October ,
            ( SELECT count(1) November FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-11')
            )AS November ,
            ( SELECT count(1) December FROM archives_borrow ab
                left JOIN archives_master am on am.archives_id = ab.archives_id
                WHERE 1=1 and am.deleted = '0' AND am.type='0' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-12')
            )AS December
        )
    </select>
    <select id="selectJkJyListByMonth" resultType="java.util.HashMap">
        SELECT * FROM (
            ( SELECT count(1) January FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-01')
            )AS January ,
            ( SELECT count(1) February FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-02')
            )AS February ,
            ( SELECT count(1) March FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-03')
            )AS March ,
            ( SELECT count(1) April FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-04')
            )AS April ,
            ( SELECT count(1) May FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-05')
            )AS May ,
            ( SELECT count(1) June FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-06')
            )AS June ,
            ( SELECT count(1) July FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-07')
            )AS July ,
            ( SELECT count(1) August FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-08')
            )AS August ,
            ( SELECT count(1) September FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-09')
            )AS September ,
            ( SELECT count(1) October FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-10')
            )AS October ,
            ( SELECT count(1) November FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-11')
            )AS November ,
            ( SELECT count(1) December FROM archives_borrow ab
            left JOIN archives_master am on am.archives_id = ab.archives_id
            WHERE 1=1 and am.deleted = '0' AND am.type='1' AND date_format(ab.create_time,'%Y-%m')=date_format(now(),'%Y-12')
            )AS December
        )
    </select>

</mapper>