部门查询优化

This commit is contained in:
zhanghan11 2024-06-17 17:52:10 +08:00
parent 5a7dc70eba
commit f4b152c3b0
8 changed files with 36 additions and 31 deletions

View File

@ -25,22 +25,24 @@ public class DeptIdAspect {
* 在service层前添加tanentId的值
*/
//@Before(value = "execution(* com.inspur..*.*ServiceImpl.*(..))")
// @Before(value = "execution(* com.inspur.equip..*.*ServiceImpl.*(..)) || execution(* com.inspur.industrial..*.*ServiceImpl.*(..))" +
// "|| execution(* com.inspur.sensor..*.*ServiceImpl.*(..)) || execution(* com.inspur.patrol..*.*ServiceImpl.*(..)) " +
// "|| execution(* com.inspur.spareparts..*.*ServiceImpl.*(..))")
// public void beforeService(JoinPoint point) {
// Object[] args = point.getArgs();
// for (Object arg : args) {
// if (arg instanceof DeptId) {
// LOGGER.info("匹配到需要注入部门id", arg);
// DeptId entity = (DeptId) arg;
// if (StringUtils.isNotNull(SecurityUtils.getAuthentication()) && !"anonymousUser".equals(SecurityUtils.getAuthentication().getPrincipal())
// && StringUtils.isNotNull(SecurityUtils.getLoginUser().getDeptId())) {
// LOGGER.info("部门id注入", entity);
// entity.setDeptId(SecurityUtils.getLoginUser().getDeptId());
// }
// }
// }
// }
@Before(value = "" +
// "execution(* com.inspur.equip..*.*ServiceImpl.*(..)) || execution(* com.inspur.industrial..*.*ServiceImpl.*(..))" +
// "|| execution(* com.inspur.sensor..*.*ServiceImpl.*(..)) ||" +
" execution(* com.inspur.patrol..*.*ServiceImpl.*(..)) " +
"|| execution(* com.inspur.spareparts..*.*ServiceImpl.*(..))")
public void beforeService(JoinPoint point) {
Object[] args = point.getArgs();
for (Object arg : args) {
if (arg instanceof DeptId) {
LOGGER.info("匹配到需要注入部门id", arg);
DeptId entity = (DeptId) arg;
if (StringUtils.isNotNull(SecurityUtils.getAuthentication()) && !"anonymousUser".equals(SecurityUtils.getAuthentication().getPrincipal())
&& StringUtils.isNotNull(SecurityUtils.getLoginUser().getDeptId())) {
LOGGER.info("部门id注入", entity);
entity.setDeptId(SecurityUtils.getLoginUser().getDeptId());
}
}
}
}
}

View File

@ -63,7 +63,7 @@
<if test="status != null ">and p.status = #{status}</if>
<if test="starttime != null ">and DATE(p.starttime) >= DATE(#{starttime})</if>
<if test="endtime != null ">and DATE(p.starttime) &lt;= DATE(#{endtime})</if>
<if test="deptId != null ">and p.dept_id = #{deptId}</if>
<if test="deptId != null ">and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))</if>
<if test="type != null ">and p.type = #{type}</if>
</where>
order by p.starttime desc, p.type desc

View File

@ -56,11 +56,14 @@
<if test="actualTime != null ">and DATE(t.actual_time) = DATE(#{actualTime})</if>
<if test="status != null ">and t.status = #{status}</if>
<if test="equipId != null ">and t.equip_id = #{equipId}</if>
<if test="deptId != null ">and t.dept_id = #{deptId}</if>
<if test="deptId != null "> and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))
</if>
<if test="executorId != null ">and t.executor_id = #{executorId}</if>
<if test="executor != null ">and e.nick_name like concat('%',#{executor},'%')</if>
<if test="type != null ">and t.type = #{type}</if>
<if test="isViolation != null">and (t.actual_time > t.plan_time or (t.actual_time is null and sysdate() > t.plan_time))</if>
<if test="isViolation != null">and (t.actual_time > t.plan_time or (t.actual_time is null and sysdate() >
t.plan_time))
</if>
</where>
order by t.status,t.type desc,t.plan_time desc
</select>
@ -114,7 +117,7 @@
<if test="planTime != null">plan_time = #{planTime},</if>
<if test="actualTime != null">actual_time = #{actualTime},</if>
<if test="status != null">status = #{status},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="executorId != null">executor_id = #{executorId},</if>
<if test="patrolContent != null">patrol_content = #{patrolContent},</if>
<if test="remark != null">remark = #{remark},</if>
@ -136,7 +139,7 @@
</foreach>
</delete>
<select id="getWordorderNum" parameterType="int" resultType="int">
SELECT IFNULL(MAX(RIGHT(task_num,4)),0)+0
SELECT IFNULL(MAX(RIGHT (task_num, 4)), 0) + 0
FROM ipc_patrol_task
WHERE DATE (SYSDATE()) = DATE (create_time)
AND type = #{type}

View File

@ -95,7 +95,7 @@
<if test="operatorId != null ">and i.operator_id = #{operatorId}</if>
<if test="auditorId != null ">and i.auditor_id = #{auditorId}</if>
<if test="status != null ">and i.status = #{status}</if>
<if test="deptId != null ">and i.dept_id = #{deptId}</if>
<if test="deptId != null ">and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))</if>
<if test="params != null and params.starttime != null">and i.inbound_time >= #{params.starttime}</if>
<if test="params != null and params.endtime != null">and i.inbound_time &lt;= #{params.endtime}</if>
</where>
@ -119,7 +119,7 @@
<if test="operatorId != null ">and i.operator_id = #{operatorId}</if>
<if test="auditorId != null ">and i.auditor_id = #{auditorId}</if>
<if test="status != null ">and i.status = #{status}</if>
<if test="deptId != null ">and i.dept_id = #{deptId}</if>
<if test="deptId != null ">and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))</if>
<if test="params != null and params.starttime != null">and i.inbound_time >= #{params.starttime}</if>
<if test="params != null and params.endtime != null">and i.inbound_time &lt;= #{params.endtime}</if>
</where>

View File

@ -102,7 +102,7 @@
<if test="unit != null and unit != ''">and i.unit = #{unit}</if>
<if test="storageLocation != null and storageLocation != ''">and i.storage_location = #{storageLocation}
</if>
<if test="deptId != null ">and i.dept_id = #{deptId}</if>
<if test="deptId != null ">and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))</if>
<if test="status != null and status != ''">and i.status = #{status}</if>
<if test="equipId != null and equipId != ''">and i.equip_id = #{equipId}</if>
<if test="params != null and params.stockNum != null and params.stockNum != ''">and s.stock_num like concat('%', #{stockNum}, '%')</if>
@ -210,7 +210,7 @@
<if test="unit != null and unit != ''">and i.unit = #{unit}</if>
<if test="storageLocation != null and storageLocation != ''">and i.storage_location = #{storageLocation}
</if>
<if test="deptId != null ">and i.dept_id = #{deptId}</if>
<if test="deptId != null ">and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))</if>
<if test="status != null and status != ''">and i.status = #{status}</if>
<if test="equipId != null and equipId != ''">and i.equip_id = #{equipId}</if>
<if test="params != null and params.stockNum != null and params.stockNum != ''">and s.stock_num like concat('%', #{stockNum}, '%')</if>

View File

@ -56,7 +56,7 @@
<if test="params != null and params.endtime != null">and i.inventory_time &lt;= #{params.endtime}</if>
<if test="status != null ">and i.status = #{status}</if>
<if test="operatorId != null ">and i.operator_id = #{operatorId}</if>
<if test="deptId != null ">and i.dept_id = #{deptId}</if>
<if test="deptId != null ">and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))</if>
<if test="result != null and result != ''">and i.result = #{result}</if>
<if test="reason != null and reason != ''">and i.reason = #{reason}</if>
<if test="completeTime != null ">and i.complete_time = #{completeTime}</if>
@ -110,7 +110,7 @@
<if test="remark != null">remark = #{remark},</if>
<if test="status != null">status = #{status},</if>
<if test="operatorId != null">operator_id = #{operatorId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="result != null">result = #{result},</if>
<if test="reason != null">reason = #{reason},</if>
<if test="createTime != null">create_time = #{createTime},</if>

View File

@ -106,7 +106,7 @@
<if test="operatorId != null ">and o.operator_id = #{operatorId}</if>
<if test="auditorId != null ">and o.auditor_id = #{auditorId}</if>
<if test="status != null ">and o.status = #{status}</if>
<if test="deptId != null ">and o.dept_id = #{deptId}</if>
<if test="deptId != null ">and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))</if>
<if test="params != null and params.starttime != null">and o.outbound_time >= #{params.starttime}</if>
<if test="params != null and params.endtime != null">and o.outbound_time &lt;= #{params.endtime}</if>
</where>
@ -137,7 +137,7 @@
<if test="operatorId != null ">and o.operator_id = #{operatorId}</if>
<if test="auditorId != null ">and o.auditor_id = #{auditorId}</if>
<if test="status != null ">and o.status = #{status}</if>
<if test="deptId != null ">and o.dept_id = #{deptId}</if>
<if test="deptId != null ">and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))</if>
<if test="params != null and params.starttime != null">and o.outbound_time >= #{params.starttime}</if>
<if test="params != null and params.endtime != null">and o.outbound_time &lt;= #{params.endtime}</if>
</where>

View File

@ -28,7 +28,7 @@
<if test="sparePartsId != null and sparePartsId != ''">and s.spare_parts_id = #{sparePartsId}</if>
<if test="quantity != null ">and s.quantity = #{quantity}</if>
<if test="safeQuantity != null ">and s.safe_quantity = #{safeQuantity}</if>
<if test="deptId != null ">and s.dept_id = #{deptId}</if>
<if test="deptId != null ">and (d.dept_id = #{deptId} or find_in_set( #{deptId} , d.ancestors ))</if>
</where>
order by s.stockNum
</select>