Browse Source

公司 部门 级 合同sql修改

[user3] 3 years atrás
parent
commit
cf3a04fc6d

+ 7 - 7
src/main/resources/mappings/modules/statement/StatementCompanyComprehensiveDao.xml

@@ -327,26 +327,26 @@
 
 	<select id="getInsertContractCountByOffice" resultType="java.lang.Integer">
 		select count(1) from work_contract_info a
-		left join work_contract_record wcr on wcr.contract_info_id = a.id
 		<where>
 			and a.del_flag=0
 			and a.contract_state = 5
 			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
-			and wcr.accomplish_date >= #{beginDate}
-			and wcr.accomplish_date &lt;= #{endDate}
+			and a.accomplish_date >= #{beginDate}
+			and a.accomplish_date &lt;= #{endDate}
 		</where>
 	</select>
 
 	<select id="getInsertContractRecordCountByOffice" resultType="java.lang.Integer">
 		select count(1) from work_contract_info a
+		left join work_contract_record wcr on wcr.contract_info_id = a.id
 		<where>
 			and a.del_flag=0
 			and a.contract_state = 5
 			and a.contract_record_state = 5
 			and a.over_due_status = 0
 			and a.office_id in(select id  from sys_office where id = #{officeId} or parent_ids like concat('%',#{officeId},'%'))
-			and a.accomplish_date >= #{beginDate}
-			and a.accomplish_date &lt;= #{endDate}
+			and wcr.accomplish_date >= #{beginDate}
+			and wcr.accomplish_date &lt;= #{endDate}
 		</where>
 	</select>
 
@@ -724,8 +724,8 @@
 			and a.contract_record_state = 5
 			and a.over_due_status = 0
 			and a.create_by = #{userId}
-			and awcr.accomplish_date >= #{beginDate}
-			and awcr.accomplish_date &lt;= #{endDate}
+			and wcr.accomplish_date >= #{beginDate}
+			and wcr.accomplish_date &lt;= #{endDate}
 		</where>
 	</select>
 

+ 55 - 31
src/main/resources/mappings/modules/workcontractinfo/WorkContractInfoDao.xml

@@ -1514,13 +1514,19 @@
 			a.del_flag=0
 			and a.contract_state = 5
 			and a.office_id in(select id  from sys_office where id = #{officeIdd} or parent_ids like concat('%',#{officeIdd},'%'))
-			and a.accomplish_date >= #{beginDate}
-			and a.accomplish_date &lt;= #{endDate}
 
-			<if test="contractRecordState != null and contractRecordState != ''">
-				and a.contract_record_state = 5
-				and a.over_due_status = 0
-			</if>
+			<choose>
+				<when test="contractRecordState != null and contractRecordState != ''">
+					and a.contract_record_state = 5
+					and a.over_due_status = 0
+					and wcr.accomplish_date >= #{beginDate}
+					and wcr.accomplish_date &lt;= #{endDate}
+				</when>
+				<otherwise>
+					and a.accomplish_date >= #{beginDate}
+					and a.accomplish_date &lt;= #{endDate}
+				</otherwise>
+			</choose>
 
 			and (a.alter_state is null or a.alter_state ="")
 			<if test="workContractInfo.id != null and workContractInfo.id != ''">
@@ -1601,13 +1607,19 @@
 			a.del_flag=0
 			and a.contract_state = 5
 			and a.office_id in(select id  from sys_office where id = #{officeIdd} or parent_ids like concat('%',#{officeIdd},'%'))
-			and a.accomplish_date >= #{beginDate}
-			and a.accomplish_date &lt;= #{endDate}
 
-			<if test="contractRecordState != null and contractRecordState != ''">
-				and a.contract_record_state = 5
-				and a.over_due_status = 0
-			</if>
+			<choose>
+				<when test="contractRecordState != null and contractRecordState != ''">
+					and a.contract_record_state = 5
+					and a.over_due_status = 0
+					and wcr.accomplish_date >= #{beginDate}
+					and wcr.accomplish_date &lt;= #{endDate}
+				</when>
+				<otherwise>
+					and a.accomplish_date >= #{beginDate}
+					and a.accomplish_date &lt;= #{endDate}
+				</otherwise>
+			</choose>
 
 			and (a.alter_state is null or a.alter_state ="")
 			<if test="workContractInfo.id != null and workContractInfo.id != ''">
@@ -1758,13 +1770,13 @@
 			and a.over_due_status = 1
 
 			<if test="statementCompanyComprehensiveInfo.field3 != null and statementCompanyComprehensiveInfo.field3 != ''">
-				and a.contract_record_state = 6
+				and a.contract_record_state != 7
 			</if>
 
 			<if test="statementCompanyComprehensiveInfo.field4 != null and statementCompanyComprehensiveInfo.field4 != ''">
 				and a.contract_record_state = 7
-				and a.accomplish_date >= #{beginDate}
-				and a.accomplish_date &lt;= #{endDate}
+				and wcr.accomplish_date >= #{beginDate}
+				and wcr.accomplish_date &lt;= #{endDate}
 			</if>
 
 			and (a.alter_state is null or a.alter_state ="")
@@ -1931,14 +1943,20 @@
 			a.del_flag=0
 			and a.contract_state = 5
 			and a.office_id in(select id  from sys_office where id = #{officeIdd} or parent_ids like concat('%',#{officeIdd},'%'))
-			and a.accomplish_date >= #{beginDate}
-			and a.accomplish_date &lt;= #{endDate}
 			and a.create_by = #{statementCompanyComprehensiveInfo.userId}
 
-			<if test="contractRecordState != null and contractRecordState != ''">
-				and a.contract_record_state = 5
-				and a.over_due_status = 0
-			</if>
+			<choose>
+				<when test="contractRecordState != null and contractRecordState != ''">
+					and a.contract_record_state = 5
+					and a.over_due_status = 0
+					and wcr.accomplish_date >= #{beginDate}
+					and wcr.accomplish_date &lt;= #{endDate}
+				</when>
+				<otherwise>
+					and a.accomplish_date >= #{beginDate}
+					and a.accomplish_date &lt;= #{endDate}
+				</otherwise>
+			</choose>
 
 			and (a.alter_state is null or a.alter_state ="")
 			<if test="workContractInfo.id != null and workContractInfo.id != ''">
@@ -2019,14 +2037,20 @@
 			a.del_flag=0
 			and a.contract_state = 5
 			and a.office_id in(select id  from sys_office where id = #{officeIdd} or parent_ids like concat('%',#{officeIdd},'%'))
-			and a.accomplish_date >= #{beginDate}
-			and a.accomplish_date &lt;= #{endDate}
 			and a.create_by = #{statementCompanyComprehensiveInfo.userId}
 
-			<if test="contractRecordState != null and contractRecordState != ''">
-				and a.contract_record_state = 5
-				and a.over_due_status = 0
-			</if>
+			<choose>
+				<when test="contractRecordState != null and contractRecordState != ''">
+					and a.contract_record_state = 5
+					and a.over_due_status = 0
+					and wcr.accomplish_date >= #{beginDate}
+					and wcr.accomplish_date &lt;= #{endDate}
+				</when>
+				<otherwise>
+					and a.accomplish_date >= #{beginDate}
+					and a.accomplish_date &lt;= #{endDate}
+				</otherwise>
+			</choose>
 
 			and (a.alter_state is null or a.alter_state ="")
 			<if test="workContractInfo.id != null and workContractInfo.id != ''">
@@ -2172,19 +2196,19 @@
 			and sodi.big_date_type = #{statementCompanyComprehensiveInfo.bigDateType}
 			and sodi.small_date_type = #{statementCompanyComprehensiveInfo.smallDateType}
 			and sodi.office_id = #{officeIdd}
+			and a.create_by = #{statementCompanyComprehensiveInfo.userId}
 			and a.contract_state = 5
 			and a.office_id in(select id  from sys_office where id = #{officeIdd} or parent_ids like concat('%',#{officeIdd},'%'))
 			and a.over_due_status = 1
-			and a.create_by = #{statementCompanyComprehensiveInfo.userId}
 
 			<if test="statementCompanyComprehensiveInfo.field3 != null and statementCompanyComprehensiveInfo.field3 != ''">
-				and a.contract_record_state = 6
+				and a.contract_record_state != 7
 			</if>
 
 			<if test="statementCompanyComprehensiveInfo.field4 != null and statementCompanyComprehensiveInfo.field4 != ''">
 				and a.contract_record_state = 7
-				and a.accomplish_date >= #{beginDate}
-				and a.accomplish_date &lt;= #{endDate}
+				and wcr.accomplish_date >= #{beginDate}
+				and wcr.accomplish_date &lt;= #{endDate}
 			</if>
 
 			and (a.alter_state is null or a.alter_state ="")