部门查询优化

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的值 * 在service层前添加tanentId的值
*/ */
//@Before(value = "execution(* com.inspur..*.*ServiceImpl.*(..))") //@Before(value = "execution(* com.inspur..*.*ServiceImpl.*(..))")
// @Before(value = "execution(* com.inspur.equip..*.*ServiceImpl.*(..)) || execution(* com.inspur.industrial..*.*ServiceImpl.*(..))" + @Before(value = "" +
// "|| execution(* com.inspur.sensor..*.*ServiceImpl.*(..)) || execution(* com.inspur.patrol..*.*ServiceImpl.*(..)) " + // "execution(* com.inspur.equip..*.*ServiceImpl.*(..)) || execution(* com.inspur.industrial..*.*ServiceImpl.*(..))" +
// "|| execution(* com.inspur.spareparts..*.*ServiceImpl.*(..))") // "|| execution(* com.inspur.sensor..*.*ServiceImpl.*(..)) ||" +
// public void beforeService(JoinPoint point) { " execution(* com.inspur.patrol..*.*ServiceImpl.*(..)) " +
// Object[] args = point.getArgs(); "|| execution(* com.inspur.spareparts..*.*ServiceImpl.*(..))")
// for (Object arg : args) { public void beforeService(JoinPoint point) {
// if (arg instanceof DeptId) { Object[] args = point.getArgs();
// LOGGER.info("匹配到需要注入部门id", arg); for (Object arg : args) {
// DeptId entity = (DeptId) arg; if (arg instanceof DeptId) {
// if (StringUtils.isNotNull(SecurityUtils.getAuthentication()) && !"anonymousUser".equals(SecurityUtils.getAuthentication().getPrincipal()) LOGGER.info("匹配到需要注入部门id", arg);
// && StringUtils.isNotNull(SecurityUtils.getLoginUser().getDeptId())) { DeptId entity = (DeptId) arg;
// LOGGER.info("部门id注入", entity); if (StringUtils.isNotNull(SecurityUtils.getAuthentication()) && !"anonymousUser".equals(SecurityUtils.getAuthentication().getPrincipal())
// entity.setDeptId(SecurityUtils.getLoginUser().getDeptId()); && 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="status != null ">and p.status = #{status}</if>
<if test="starttime != null ">and DATE(p.starttime) >= DATE(#{starttime})</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="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> <if test="type != null ">and p.type = #{type}</if>
</where> </where>
order by p.starttime desc, p.type desc 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="actualTime != null ">and DATE(t.actual_time) = DATE(#{actualTime})</if>
<if test="status != null ">and t.status = #{status}</if> <if test="status != null ">and t.status = #{status}</if>
<if test="equipId != null ">and t.equip_id = #{equipId}</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="executorId != null ">and t.executor_id = #{executorId}</if>
<if test="executor != null ">and e.nick_name like concat('%',#{executor},'%')</if> <if test="executor != null ">and e.nick_name like concat('%',#{executor},'%')</if>
<if test="type != null ">and t.type = #{type}</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> </where>
order by t.status,t.type desc,t.plan_time desc order by t.status,t.type desc,t.plan_time desc
</select> </select>

View File

@ -95,7 +95,7 @@
<if test="operatorId != null ">and i.operator_id = #{operatorId}</if> <if test="operatorId != null ">and i.operator_id = #{operatorId}</if>
<if test="auditorId != null ">and i.auditor_id = #{auditorId}</if> <if test="auditorId != null ">and i.auditor_id = #{auditorId}</if>
<if test="status != null ">and i.status = #{status}</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.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> <if test="params != null and params.endtime != null">and i.inbound_time &lt;= #{params.endtime}</if>
</where> </where>
@ -119,7 +119,7 @@
<if test="operatorId != null ">and i.operator_id = #{operatorId}</if> <if test="operatorId != null ">and i.operator_id = #{operatorId}</if>
<if test="auditorId != null ">and i.auditor_id = #{auditorId}</if> <if test="auditorId != null ">and i.auditor_id = #{auditorId}</if>
<if test="status != null ">and i.status = #{status}</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.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> <if test="params != null and params.endtime != null">and i.inbound_time &lt;= #{params.endtime}</if>
</where> </where>

View File

@ -102,7 +102,7 @@
<if test="unit != null and unit != ''">and i.unit = #{unit}</if> <if test="unit != null and unit != ''">and i.unit = #{unit}</if>
<if test="storageLocation != null and storageLocation != ''">and i.storage_location = #{storageLocation} <if test="storageLocation != null and storageLocation != ''">and i.storage_location = #{storageLocation}
</if> </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="status != null and status != ''">and i.status = #{status}</if>
<if test="equipId != null and equipId != ''">and i.equip_id = #{equipId}</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> <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="unit != null and unit != ''">and i.unit = #{unit}</if>
<if test="storageLocation != null and storageLocation != ''">and i.storage_location = #{storageLocation} <if test="storageLocation != null and storageLocation != ''">and i.storage_location = #{storageLocation}
</if> </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="status != null and status != ''">and i.status = #{status}</if>
<if test="equipId != null and equipId != ''">and i.equip_id = #{equipId}</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> <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="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="status != null ">and i.status = #{status}</if>
<if test="operatorId != null ">and i.operator_id = #{operatorId}</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="result != null and result != ''">and i.result = #{result}</if>
<if test="reason != null and reason != ''">and i.reason = #{reason}</if> <if test="reason != null and reason != ''">and i.reason = #{reason}</if>
<if test="completeTime != null ">and i.complete_time = #{completeTime}</if> <if test="completeTime != null ">and i.complete_time = #{completeTime}</if>

View File

@ -106,7 +106,7 @@
<if test="operatorId != null ">and o.operator_id = #{operatorId}</if> <if test="operatorId != null ">and o.operator_id = #{operatorId}</if>
<if test="auditorId != null ">and o.auditor_id = #{auditorId}</if> <if test="auditorId != null ">and o.auditor_id = #{auditorId}</if>
<if test="status != null ">and o.status = #{status}</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.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> <if test="params != null and params.endtime != null">and o.outbound_time &lt;= #{params.endtime}</if>
</where> </where>
@ -137,7 +137,7 @@
<if test="operatorId != null ">and o.operator_id = #{operatorId}</if> <if test="operatorId != null ">and o.operator_id = #{operatorId}</if>
<if test="auditorId != null ">and o.auditor_id = #{auditorId}</if> <if test="auditorId != null ">and o.auditor_id = #{auditorId}</if>
<if test="status != null ">and o.status = #{status}</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.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> <if test="params != null and params.endtime != null">and o.outbound_time &lt;= #{params.endtime}</if>
</where> </where>

View File

@ -28,7 +28,7 @@
<if test="sparePartsId != null and sparePartsId != ''">and s.spare_parts_id = #{sparePartsId}</if> <if test="sparePartsId != null and sparePartsId != ''">and s.spare_parts_id = #{sparePartsId}</if>
<if test="quantity != null ">and s.quantity = #{quantity}</if> <if test="quantity != null ">and s.quantity = #{quantity}</if>
<if test="safeQuantity != null ">and s.safe_quantity = #{safeQuantity}</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> </where>
order by s.stockNum order by s.stockNum
</select> </select>