From 00c23dd7d4a8f229d5c7fbe3439c6ea230fa7f48 Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期三, 09 四月 2025 16:20:21 +0800
Subject: [PATCH] 成品检验查询功能开发
---
inspect-server/src/main/resources/mapper/InsOrderMapper.xml | 17 ---
inspect-server/src/main/resources/mapper/InsSampleMapper.xml | 144 ++++++++++++----------------
inspect-server/src/main/java/com/ruoyi/inspect/dto/InsOrderPlanQueryDto.java | 26 +++++
inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsSampleMapper.java | 7 -
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java | 19 ---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 29 ++---
6 files changed, 100 insertions(+), 142 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/dto/InsOrderPlanQueryDto.java b/inspect-server/src/main/java/com/ruoyi/inspect/dto/InsOrderPlanQueryDto.java
new file mode 100644
index 0000000..df5168a
--- /dev/null
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/dto/InsOrderPlanQueryDto.java
@@ -0,0 +1,26 @@
+package com.ruoyi.inspect.dto;
+
+import lombok.Data;
+
+@Data
+public class InsOrderPlanQueryDto {
+
+ private Integer userId;
+
+ private String userName;
+
+ /**
+ * 鏄惁鏄楠屼汉鍛�
+ */
+ private Boolean checkUserFlag;
+
+ /**
+ * 鏄惁鏄娴嬬鐞嗕汉鍛�
+ */
+ private Boolean testAdminFlag;
+
+ /**
+ * 鏄惁涓哄彧鏌ョ湅鑷繁
+ */
+ private Boolean viewMySelfFlag;
+}
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsSampleMapper.java b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsSampleMapper.java
index 633ebc1..5782ef2 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsSampleMapper.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsSampleMapper.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.inspect.dto.InsOrderPlanDTO;
+import com.ruoyi.inspect.dto.InsOrderPlanQueryDto;
import com.ruoyi.inspect.dto.SampleProductDto;
import com.ruoyi.inspect.pojo.InsProduct;
import com.ruoyi.inspect.pojo.InsSample;
@@ -26,11 +27,7 @@
IPage<InsOrderPlanVO> findInsSampleAndOrder(Page page,
@Param("ew") QueryWrapper<InsOrderPlanDTO> ew,
- @Param("userName") String userName ,
- @Param("userId") Integer userId,
- @Param("sonLaboratory") String sonLaboratory,
- @Param("laboratory") String laboratory,
- @Param("isCheck") Integer isCheck);
+ @Param("otherParam")InsOrderPlanQueryDto otherParam);
IPage<InsOrderPlanTaskSwitchVo> inspectionOrderDetailsTaskSwitching(Page page, @Param("ew") QueryWrapper<InsOrderPlanDTO> ew, @Param("userId") Integer userId, @Param("sonLaboratory") String sonLaboratory, @Param("laboratory") String laboratory);
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
index 7168206..28effb2 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -55,6 +55,7 @@
import com.ruoyi.system.service.InformationNotificationService;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.*;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.web.MockMultipartFile;
@@ -154,28 +155,18 @@
@Override
public IPage<InsOrderPlanVO> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) {
- // todo: 浠呯湅鑷繁鎴栬�呭疄楠屽
- //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id
-
- String laboratory = null;
-
- String userName = null;
- Integer userId = null;
- if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
- userId = SecurityUtils.getUserId().intValue();
- userName = userMapper.selectById(userId).getName();
+ // 妫�娴嬬鐞嗕汉鍛樺叏鏌ワ紝闈炴娴嬬鐞嗕汉鍛樺彧鏌ョ湅鑷繁鐨�
+ InsOrderPlanQueryDto insOrderPlanQueryDto = new InsOrderPlanQueryDto();
+ insOrderPlanQueryDto.setCheckUserFlag(SecurityUtils.hasRole("inspector"));
+ insOrderPlanQueryDto.setTestAdminFlag(SecurityUtils.hasRole("testadmin"));
+ // 鍒ゆ柇鏄惁瑙﹀彂鍙煡鐪嬭嚜宸�
+ if(null != insOrderPlanDTO.getUserId()){
+ insOrderPlanQueryDto.setViewMySelfFlag(true);
insOrderPlanDTO.setUserId(null);
}
- Integer isCheck = insOrderPlanDTO.getIsCheck();
- insOrderPlanDTO.setIsCheck(null);
- String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
+ insOrderPlanQueryDto.setUserId(SecurityUtils.getUserId().intValue());
IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page,
- QueryWrappers.queryWrappers(insOrderPlanDTO),
- userName,
- userId,
- sonLaboratory,
- laboratory,
- isCheck);
+ QueryWrappers.queryWrappers(insOrderPlanDTO),insOrderPlanQueryDto);
return insOrderPage;
}
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
index ab3572e..2fe43b6 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
@@ -91,8 +91,6 @@
//鑾峰彇妫�楠屼笅鍗曟暟鎹�
@Override
public IPage<SampleOrderDto> selectInsOrderParameter(IPage<InsOrder> page, SampleOrderDto sampleOrderDto) {
- // TODO 閽堝浜哄憳鍋氭潈闄愬鐞� 鐩墠鍏堝妫�楠屼汉鍛樺仛鏁版嵁澶勭悊 濡傛灉鏄楠屼汉鍛樺彧鑳芥煡璇㈠埌妫�楠岄」鐩槸鑷繁鎴栬�呰鍗曞垎娲句汉鏄嚜宸辩殑璁㈠崟锛屼笉鏄楠屼汉鍛樼殑鏆傛椂鍏ㄦ煡
- boolean checkUserFlag = isCheckUser(SecurityUtils.getUserId().intValue());
String laboratory = null;
// 鍒ゆ柇鏄惁鏄叏閮�
String isOrderAll = null;
@@ -103,7 +101,6 @@
SampleOrderDto otherParam = new SampleOrderDto();
otherParam.setLaboratory(laboratory);
otherParam.setIsOrderAll(isOrderAll);
- otherParam.setCheckUserFlag(checkUserFlag);
otherParam.setCheckUserId(SecurityUtils.getUserId());
IPage<SampleOrderDto> sampleOrderDtoIPage = insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), otherParam);
return sampleOrderDtoIPage;
@@ -1037,22 +1034,6 @@
} catch (IOException e) {
throw new RuntimeException("瀵煎嚭澶辫触");
}
- }
-
-
- /**
- * 鍒ゆ柇鏄惁涓烘楠屼汉鍛�
- * @param userId
- * @return
- */
- public boolean isCheckUser(Integer userId) {
- List<User> userList = userMapper.selectQualityUserList();
- for (User user : userList) {
- if(userId.equals(user.getId())){
- return true;
- }
- }
- return false;
}
}
diff --git a/inspect-server/src/main/resources/mapper/InsOrderMapper.xml b/inspect-server/src/main/resources/mapper/InsOrderMapper.xml
index 24c7c12..de0250d 100644
--- a/inspect-server/src/main/resources/mapper/InsOrderMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsOrderMapper.xml
@@ -96,23 +96,6 @@
<if test="otherParam.laboratory!=null and otherParam.laboratory!=''">
AND io.laboratory=#{otherParam.laboratory}
</if>
- <if test="otherParam.checkUserFlag != null and otherParam.checkUserFlag and otherParam.checkUserId != null ">
- AND io.id IN (
- SELECT DISTINCT
- ins_sample_id AS orderId
- FROM
- ins_sample_user
- WHERE
- user_id = #{otherParam.checkUserId} UNION
- SELECT
- T2.ins_order_id AS orderId
- FROM
- ins_product T1
- JOIN ins_sample T2 ON T1.ins_sample_id = T2.id
- WHERE
- T1.check_user_id = #{otherParam.checkUserId}
- )
- </if>
GROUP BY io.id,type
order by type desc,io.id desc
) a
diff --git a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
index 84af8bb..a918f7b 100644
--- a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
@@ -164,88 +164,68 @@
<select id="findInsSampleAndOrder" resultType="com.ruoyi.inspect.vo.InsOrderPlanVO">
- select * from(select * from(
- SELECT
- a.*,ios.ins_state,ios.verify_tell,verify_user
- FROM
- (
- SELECT
- io.id,
- io.entrust_code,
- io.type,
- io.appointed,
- io.send_time,
- io.order_type,
- case when
- io.type_source = 0
- then io.sample_view
- else io.sample end sample,
- GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model,
- userName,
- checkName,
- ip.son_laboratory,
- io.ins_time,
- io.laboratory,
- io.type_source,
- io.ifs_inventory_id,
- ira.id ins_report_id,
- ira.url,
- ira.url_s,
- ira.temp_url_pdf,
- iiq.is_copper
- FROM
- ins_order io
- LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id
- LEFT JOIN ins_report ira ON ira.ins_order_id = io.id
- LEFT JOIN ifs_inventory_quantity iiq ON iiq.id = io.ifs_inventory_id
- LEFT JOIN (
- SELECT ins_sample_id,GROUP_CONCAT( DISTINCT uu.name SEPARATOR ',') AS userName
- FROM ins_sample_user u LEFT JOIN user uu ON u.user_id = uu.id
- WHERE u.state=0
- <if test="sonLaboratory!= null and sonLaboratory != ''">
- and son_laboratory=#{sonLaboratory}
- </if>
- GROUP BY ins_sample_id
- ORDER BY ins_sample_id
- ) isu ON isu.ins_sample_id = io.id
- LEFT JOIN (
- SELECT ins_sample_id,uu.name checkName
- FROM ins_sample_user u LEFT JOIN user uu ON u.user_id = uu.id
- WHERE u.state=1
- <if test="sonLaboratory!= null and sonLaboratory != ''">
- and son_laboratory=#{sonLaboratory}
- </if>
- GROUP BY ins_sample_id
- ORDER BY ins_sample_id
- )isu2 ON isu2.ins_sample_id = io.id
- LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id
- WHERE io.state = 1 and send_time is not null
- <if test="isCheck != null">
- <if test="userName !=null and userName!=''">
- and checkName like CONCAT ('%', #{userName},'%')
- </if>
- </if>
- <if test="isCheck == null">
- <if test="userName !=null and userName!=''">
- and userName like CONCAT ('%', #{userName},'%')
- </if>
- </if>
- <if test="sonLaboratory!= null and sonLaboratory != ''">
- and ip.son_laboratory = #{sonLaboratory}
- </if>
- GROUP BY
- ip.son_laboratory,
- io.id
- ) a
- LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory
- ORDER BY
- a.type DESC,
- a.id
- ) b
- where ins_state is not null
- <if test="laboratory!=null and laboratory!=''">
- and laboratory=#{laboratory}
- </if>
+ select * from(
+ select * from(
+ SELECT a.*,ios.ins_state,ios.verify_tell,verify_user
+ FROM
+ (
+ SELECT
+ io.id,
+ io.entrust_code,
+ io.type,
+ io.appointed,
+ io.send_time,
+ io.order_type,
+ case when
+ io.type_source = 0
+ then io.sample_view
+ else io.sample end sample,
+ GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model,
+ T4.userName,
+ ip.son_laboratory,
+ io.ins_time,
+ io.laboratory,
+ io.type_source,
+ io.ifs_inventory_id,
+ ira.id ins_report_id,
+ ira.url,
+ ira.url_s,
+ ira.temp_url_pdf,
+ iiq.is_copper
+ FROM
+ ins_order io
+ LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id
+ LEFT JOIN ins_report ira ON ira.ins_order_id = io.id
+ LEFT JOIN ifs_inventory_quantity iiq ON iiq.id = io.ifs_inventory_id
+ LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id
+ LEFT JOIN ins_sample_user isu ON isa.id = isu.user_id
+ LEFT JOIN user uu ON ip.check_user_id = uu.id
+ LEFT JOIN (
+ SELECT T1.ins_order_id,GROUP_CONCAT( DISTINCT T3.name SEPARATOR ', ' ) AS userName FROM ins_sample T1 LEFT JOIN ins_product T2 ON T1.id = T2.ins_sample_id LEFT JOIN user T3 ON T2.check_user_id = T3.id GROUP BY T1.ins_order_id
+ ) T4 ON T4.ins_order_id = io.id
+ WHERE io.state = 1 and send_time is not null
+ -- 闈炴娴嬬鐞嗗憳
+ <if test="otherParam.testAdminFlag != null and !otherParam.testAdminFlag">
+ <if test="otherParam.checkUserFlag != null and otherParam.checkUserFlag">
+ AND (
+ isu.user_id = #{otherParam.userId} OR ip.check_user_id = #{otherParam.userId}
+ )
+ </if>
+ </if>
+ -- 鏄娴嬬鐞嗗憳
+ <if test="otherParam.testAdminFlag != null and otherParam.testAdminFlag">
+ <if test="otherParam.viewMySelfFlag != null and otherParam.viewMySelfFlag">
+ AND (
+ isu.user_id = #{otherParam.userId} OR ip.check_user_id = #{otherParam.userId}
+ )
+ </if>
+ </if>
+ GROUP BY io.id
+ ) a
+ LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory
+ ORDER BY a.type DESC,a.id
+ ) b
+ where ins_state is not null
)A
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment}
--
Gitblit v1.9.3