1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?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.yiboshi.science.dao.ComUnitDAO">
<sql id="allColumns">
t.id as id, t.tree_code as treeCode, t.unit_name as unitName, t.unit_type as unitType, t.unit_level as unitLevel, t.note_state as noteState, t.unit_address as unitAddress, t.postcode as postcode,
t.link_name as linkName, t.link_tel as linkTel, t.link_email as linkEmail, t.proj_limit as projLimit, t.remark as remark, t.created as created, t.updated as updated
</sql>
<select id="getList" resultType="com.yiboshi.science.param.dto.ComUnitDTO">
select a.*,
b.unit_name as upUnitName,b.tree_code as upTreeCode,c.name natureName
from com_unit a
left join com_unit b on substring(a.tree_code, 1, length(a.tree_code) - 5) = b.tree_code
left join system_parameter c on a.unit_nature = c.id and c.type_id = 58
where (a.audit_result=10 or a.audit_result is null) and a.unit_state=1
ORDER BY a.unit_type ASC , a.tree_code ASC
</select>
<select id="getUnitById" resultType="com.yiboshi.science.param.dto.ComUnitDTO">
select a.*,b.unit_name as upUnitName,b.tree_code as upTreeCode
from com_unit a
left join com_unit b on substring(a.tree_code, 1, length(a.tree_code) - 5) = b.tree_code
where a.id = #{id}
</select>
<select id="getUnitByTreeCode" resultType="com.yiboshi.science.param.dto.ComUnitDTO">
select a.*
from com_unit a
where a.tree_code = #{treeCode}
</select>
<select id="getListByPage" resultType="com.yiboshi.science.param.dto.ComUnitDTO">
select a.*, b.username, b.password, c.unit_name as upUnitName,d.name natureName
from com_unit a
left join system_user b on a.id = b.person_id
left join com_unit c on substring(a.tree_code, 1, length(a.tree_code) - 5) = c.tree_code
left join system_parameter d on a.unit_nature = d.id and d.type_id = 58
<where>
${ew.sqlSegment}
</where>
ORDER BY a.tree_code ASC,a.unit_type ASC
</select>
<select id="getMaxTreeCode" parameterType="java.lang.String" resultType="java.lang.String">
select CONCAT('0000',cast((ifnull(SUBSTR(max(tree_code),LENGTH(max(tree_code))-4),0)+1) as char)) code
from com_unit
where tree_code like concat(#{code}, '_____')
</select>
<select id="getRegisterUnitCount" resultType="com.yiboshi.science.param.dto.DataStatisticsDTO">
SELECT ifnull(sum(case when a.audit_result is not null and a.audit_result=1 then 1 else 0 end),0) count1,
ifnull(sum(case when a.audit_result is not null and a.audit_result>1 then 1 else 0 end),0) count2,
ifnull(sum(case when a.audit_result is not null then 1 else 0 end),0) count5
FROM com_unit a
<where>
${ew.sqlSegment}
</where>
</select>
<select id="getRegisterUnitCountByDay" resultType="com.yiboshi.science.param.dto.DataStatisticsDTO">
SELECT ifnull(count(1),0) count1
FROM com_unit a
<where>
${ew.sqlSegment} and TO_DAYS(a.created) = TO_DAYS(NOW())
</where>
</select>
<!-- <select id="getUnitByTreeCode" parameterType="java.lang.String" resultType="com.yiboshi.science.param.query.ComUnitQueryVO">-->
<!-- select *-->
<!-- from com_unit-->
<!-- where tree_code like concat(#{treeCode}, '%') and tree_code !='53' order by unit_type,tree_code-->
<!-- </select>-->
</mapper>