From 8e2b983273b816b33e7456f6c30a2577d443fb43 Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期四, 22 四月 2021 10:26:44 +0800
Subject: [PATCH] 根据课题组展示库存情况
---
src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml | 119 +++++++++++++++++++++++++++++++++++++--
src/main/webapp/laboratory_stock_mng.xhtml | 4
src/main/java/com/nanometer/smartlab/service/OpeReagentStatusServiceImpl.java | 29 +++++++++
3 files changed, 142 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml b/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml
index 25b2cd3..52a4829 100644
--- a/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml
+++ b/src/main/java/com/nanometer/smartlab/dao/OpeReagentStatusDao.xml
@@ -206,12 +206,71 @@
</select>
<select id="getOpeReagentStatusListForLab" parameterType="java.util.Map" resultMap="OpeReagentStatus">
- <include refid="queryColumns"/>
+ select oa.*,
+ sr.*,
+ sr.id as reagentId,
+ su.name as userName,
+ <if test="status != null">
+ <choose>
+ <when test="status == 1 or status == 2">
+ swc.container_code as containerCode,
+ sw.name as houseName,
+ </when>
+ </choose>
+ </if>
+ ss.name as supplierName
from ope_reagent_status as oa
- <include refid="queryJoins"/>
+ left join sys_reagent sr on oa.reagent_id = sr.id
+ left join sys_supplier as ss on sr.supplier_id = ss.id
+ left join sys_user as su on oa.user_id = su.id
+ <if test="status != null">
+ <choose>
+ <when test="status == 1">
+ left join sys_warehouse as sw on sw.id = oa.house_id
+ left join sys_warehouse_container as swc on swc.id = oa.container_id
+ </when>
+ <when test="status == 2">
+ left join sys_laboratory as sw on sw.id = oa.house_id
+ left join sys_laboratory_container as swc on swc.id = oa.container_id
+ </when>
+ </choose>
+ </if>
where oa.valid_flag = 1
- <include refid="queryWhereSqlForLab"/>
-
+ <if test="reagentId != null and reagentId != ''">
+ and oa.reagent_id = #{reagentId}
+ </if>
+ <if test="userId != null and userId != ''">
+ and oa.user_id = #{userId}
+ </if>
+ <if test="department != null and department != ''">
+ and sw.department = #{department}
+ </if>
+ <if test="departmentUserIds != null">
+ and oa.user_id in
+ <foreach collection="departmentUserIds" item="item" index="index" open="(" separator="," close=")">
+ #{item}
+ </foreach>
+ </if>
+ <if test="articleNumber != null and articleNumber != ''">
+ and oa.article_number = #{articleNumber}
+ </if>
+ <if test="editId != null and editId != ''">
+ and oa.id != #{editId}
+ </if>
+ <if test="reagentCode != null and reagentCode != ''">
+ and oa.reagent_code like #{reagentCode}
+ </if>
+ <if test="status != null">
+ and oa.status = #{status}
+ </if>
+ <if test="name != null and name != ''">
+ and sr.name like #{name}
+ </if>
+ <choose>
+ <when test="status == 2 and project != null and project != ''">
+ and sw.project like concat("%",#{project},"%")
+ </when>
+ </choose>
order by oa.reagent_code asc
<if test="first != null and pageSize != null">
limit #{first}, #{pageSize}
@@ -251,9 +310,57 @@
<select id="getOpeReagentStatusTotalCountForLab" parameterType="java.util.Map" resultType="int">
select count(1)
from ope_reagent_status as oa
- <include refid="queryJoins"/>
+ left join sys_reagent sr on oa.reagent_id = sr.id
+ left join sys_supplier as ss on sr.supplier_id = ss.id
+ left join sys_user as su on oa.user_id = su.id
+ <if test="status != null">
+ <choose>
+ <when test="status == 1">
+ left join sys_warehouse as sw on sw.id = oa.house_id
+ left join sys_warehouse_container as swc on swc.id = oa.container_id
+ </when>
+ <when test="status == 2">
+ left join sys_laboratory as sw on sw.id = oa.house_id
+ left join sys_laboratory_container as swc on swc.id = oa.container_id
+ </when>
+ </choose>
+ </if>
where oa.valid_flag = 1
- <include refid="queryWhereSqlForLab"/>
+ <if test="reagentId != null and reagentId != ''">
+ and oa.reagent_id = #{reagentId}
+ </if>
+ <if test="userId != null and userId != ''">
+ and oa.user_id = #{userId}
+ </if>
+ <if test="department != null and department != ''">
+ and sw.department = #{department}
+ </if>
+ <if test="departmentUserIds != null">
+ and oa.user_id in
+ <foreach collection="departmentUserIds" item="item" index="index" open="(" separator="," close=")">
+ #{item}
+ </foreach>
+ </if>
+ <if test="articleNumber != null and articleNumber != ''">
+ and oa.article_number = #{articleNumber}
+ </if>
+ <if test="editId != null and editId != ''">
+ and oa.id != #{editId}
+ </if>
+ <if test="reagentCode != null and reagentCode != ''">
+ and oa.reagent_code like #{reagentCode}
+ </if>
+ <if test="status != null">
+ and oa.status = #{status}
+ </if>
+ <if test="name != null and name != ''">
+ and sr.name like #{name}
+ </if>
+ <choose>
+ <when test="status == 2 and project != null and project != ''">
+ and sw.project like concat("%",#{project},"%")
+ </when>
+ </choose>
</select>
<select id="getPersonReagentStatusTotalCount" parameterType="java.util.Map" resultType="int">
diff --git a/src/main/java/com/nanometer/smartlab/service/OpeReagentStatusServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/OpeReagentStatusServiceImpl.java
index f4c3e7a..8b14efa 100644
--- a/src/main/java/com/nanometer/smartlab/service/OpeReagentStatusServiceImpl.java
+++ b/src/main/java/com/nanometer/smartlab/service/OpeReagentStatusServiceImpl.java
@@ -17,6 +17,7 @@
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DuplicateKeyException;
+import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -62,6 +63,8 @@
private OpeUseFlowDao opeUseFlowDao;
@Resource
private OpeWarehouseReserveDao opeWarehouseReserveDao;
+ @Resource
+ private BaseRoleService baseRoleService;
@Resource(name="baseMetaDao")
BaseMetaDao baseMetaDao;
@@ -106,7 +109,18 @@
params.put("name", "%" + name + "%");
params.put("articleNumber", articleNumber);
params.put("status", status);
- addParamByUserId(userId, params);
+// addParamByUserId(userId, params);
+ if (StringUtils.isNotBlank(userId)) {
+ SysUser sysUser = sysUserService.getSysUser(userId);
+ BaseRole baseRole = baseRoleService.getBaseRole(sysUser.getRoleId());
+ //不是系统管理员 根据用户的课题组判断可视(用户所在课题组是否 在实验室的课题组下)
+ if (!"系统管理员".equals(baseRole.getName())) {
+ if (StringUtils.isBlank(sysUser.getProject())) {
+ return null;
+ }
+ params.put("project", sysUser.getProject());
+ }
+ }
if (StringUtils.isNotBlank(reagentCode)) {
params.put("reagentCode", "%" + reagentCode + "%");
}
@@ -127,8 +141,19 @@
Map<String, Object> params = new HashMap<String, Object>();
params.put("name", "%" + name + "%");
- addParamByUserId(userId, params);
+// addParamByUserId(userId, params);
params.put("articleNumber", articleNumber);
+ if (StringUtils.isNotBlank(userId)) {
+ SysUser sysUser = sysUserService.getSysUser(userId);
+ BaseRole baseRole = baseRoleService.getBaseRole(sysUser.getRoleId());
+ //不是系统管理员 根据用户的课题组判断可视(用户所在课题组是否 在实验室的课题组下)
+ if (!"系统管理员".equals(baseRole.getName())) {
+ if (StringUtils.isBlank(sysUser.getProject())) {
+ return 0;
+ }
+ params.put("project", sysUser.getProject());
+ }
+ }
if (StringUtils.isNotBlank(reagentCode)) {
params.put("reagentCode", "%" + reagentCode + "%");
}
diff --git a/src/main/webapp/laboratory_stock_mng.xhtml b/src/main/webapp/laboratory_stock_mng.xhtml
index c863421..c85d79c 100644
--- a/src/main/webapp/laboratory_stock_mng.xhtml
+++ b/src/main/webapp/laboratory_stock_mng.xhtml
@@ -46,7 +46,7 @@
value="#{laboratoryStockMngController.reagentStatusDataModel}"
var="row" rowKey="#{row.id}" emptyMessage="无数据" rows="20"
pageLinks="5">
- <p:column headerText="实验室名">
+ <p:column headerText="实验室名" width="150">
<h:outputText value="#{row.houseName}"></h:outputText>
</p:column>
@@ -54,7 +54,7 @@
<h:outputText value="#{row.containerCode}"></h:outputText>
</p:column>
- <p:column headerText="试剂条形码">
+ <p:column headerText="试剂条形码" width="200">
<h:outputText value="#{row.reagentCode}"></h:outputText>
</p:column>
--
Gitblit v1.9.2