chenrui
2025-04-09 00c23dd7d4a8f229d5c7fbe3439c6ea230fa7f48
成品检验查询功能开发
已修改5个文件
已添加1个文件
242 ■■■■■ 文件已修改
inspect-server/src/main/java/com/ruoyi/inspect/dto/InsOrderPlanQueryDto.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsSampleMapper.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/InsOrderMapper.xml 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/InsSampleMapper.xml 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
}
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);
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;
    }
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;
    }
}
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
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}