fei
7 小时以前 bcb1d905904fd43034f7c95077336e5cb849eff1
archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
@@ -96,11 +96,12 @@
        if (StringUtils.isEmpty(categoryNumberStart) || StringUtils.isEmpty(categoryNumberEnd)) {
            lqw.like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId());
        }
        else {
     //  else {
                lqw.
            like(!StringUtils.isEmpty(archiveRecords.getInquiryNumber()), ArchiveRecords::getInquiryNumber, archiveRecords.getInquiryNumber())
                    .like(!StringUtils.isEmpty(archiveRecords.getCaseTitle()), ArchiveRecords::getCaseTitle, archiveRecords.getCaseTitle())
                    .like(!StringUtils.isEmpty(archiveRecords.getPublicAttribute()), ArchiveRecords::getPublicAttribute, archiveRecords.getPublicAttribute())
                        .like(!StringUtils.isEmpty(archiveRecords.getPublicAttribute()), ArchiveRecords::getPublicAttribute, archiveRecords.getPublicAttribute())
                    .like(!StringUtils.isEmpty(archiveRecords.getPreparationUnit()), ArchiveRecords::getPreparationUnit, archiveRecords.getPreparationUnit())
                    .like(!StringUtils.isEmpty(archiveRecords.getRetentionPeriod()), ArchiveRecords::getRetentionPeriod, archiveRecords.getRetentionPeriod())
                    .like(!StringUtils.isEmpty(archiveRecords.getSecurityClassification()), ArchiveRecords::getSecurityClassification, archiveRecords.getSecurityClassification())
@@ -117,7 +118,7 @@
                    .like(!StringUtils.isEmpty(archiveRecords.getEveryProjectName()), ArchiveRecords::getEveryProjectName, archiveRecords.getEveryProjectName())
                    .like(!StringUtils.isEmpty(archiveRecords.getRemarks()), ArchiveRecords::getRemarks, archiveRecords.getRemarks());
        }
      //  }
        if(archiveRecords.getIds()!=null)
                lqw.in(ArchiveRecords::getId,new ArrayList<>(Arrays.asList(archiveRecords.getIds())));
@@ -133,9 +134,29 @@
//                .eq(zfProperty.getHappenTime()!=null,ZfProperty::getHappenTime,zfProperty.getHappenTime())
//                .between(zfProperty.getHappenStartTime() != null && zfProperty.getHappenEndTime() != null, ZfProperty::getHappenTime, zfProperty.getHappenStartTime(), zfProperty.getHappenEndTime());
//        lqw.orderByDesc(ZfProperty::getCreateTime);
        if(userId==1)
        if(archiveRecords.getOrderByColumn()==null) {
            if (userId == 1)
            lqw.orderByDesc(ArchiveRecords::getCreateTime);
                lqw.orderByDesc(ArchiveRecords::getCreateTime);
        }else
        {
            System.out.println(archiveRecords.getOrderByColumn());
            if("recordId".equals(archiveRecords.getOrderByColumn())) {
                if (archiveRecords.getIsAsc().equals("asc"))
                    lqw.orderByAsc(ArchiveRecords::getRecordId);
                else
                    lqw.orderByDesc(ArchiveRecords::getRecordId);
            }
            if("recordStatus".equals(archiveRecords.getOrderByColumn()))
            {
                if (archiveRecords.getIsAsc().equals("asc"))
                    lqw.orderByAsc(ArchiveRecords::getRecordStatus);
                else
                    lqw.orderByDesc(ArchiveRecords::getRecordStatus);
            }
        }
       // else
       //     lqw.eq(userId!=null, ArchiveRecords::getUserId, userId);
        System.out.println("ssssssssssssddd0000000000000000");
        return lqw;
@@ -163,8 +184,11 @@
        Page<ArchiveRecords> page = new Page<>(pageNum, pageSize);
    
    // 使用自定义的分页查询方法,先连接再分页
    Page<ArchiveRecords> pageResult = this.baseMapper.selectJoinUserPage(page, userid, lqw);
    Page<ArchiveRecords> pageResult = new Page<>();
    if(userid==1)
        pageResult = this.baseMapper.selectJoinUserPage(page, userid, lqw);
    else
        pageResult = this.baseMapper.selectJoinCommonUserPage(page, userid, lqw);
            //selectJoinUserPage(page, lqw);
    
@@ -175,11 +199,12 @@
     //   log.info("从数据库中查到的为:{}", beanRecords);
    //    return markOwnData(familyId, fatherFaId, motherFaId, beanRecords);
        List<ArchiveRecords> beanUserRecords = new ArrayList<>();
        beanRecords.forEach(record ->{
            if(record.isArchiveRecordsId()!=null&&record.getUserId()==userid)
            {
                    record.setOwnData(true);
                    beanUserRecords.add(record);
            }
            else
                record.setOwnData(false);
@@ -187,7 +212,11 @@
        //不是管理员进行排序
       // if(userid != 1)
       //    Collections.sort(beanRecords, Comparator.comparing(ArchiveRecords::isOwnData));
        HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
        HashMap<String, Object> data = new HashMap<>();
        if(userid==1)
            data = MapUtils.getResult(pageResult, beanRecords);
        else
            data = MapUtils.getResult(pageResult, beanUserRecords);
//        System.out.println(data.get("data"));
//        System.out.println(data.get("pageNum"));
//        System.out.println(data.get("total"));
@@ -355,12 +384,26 @@
        }
        assert dataList != null;
      //  System.out.println("++++++++++++++++++++000000");
//        System.out.println(dataList.size());
//                for (ArchiveRecords archiveRecords : dataList) {
//                    System.out.println(dataList.size());
//
//                }
        for (ArchiveRecords archiveRecords : dataList) {
           // physcialService.mySave(physcial);
            archiveRecords.setRecordStatus("未录入");
            System.out.println(archiveRecords.getProjectName());
            LocalDateTime time = LocalDateTime.now();
            String title = "";
            if(archiveRecords.getConstructionUnit()!=null)
                title = title +archiveRecords.getConstructionUnit();
            if(archiveRecords.getConstructionAddress()!=null)
                title = title + archiveRecords.getConstructionAddress();
            if(archiveRecords.getProjectName()!=null)
                title = title + archiveRecords.getProjectName();
            archiveRecords.setCaseTitle(title);
            Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
            archiveRecords.setCreateTime(date);
            this.mySave(archiveRecords);
@@ -375,20 +418,31 @@
    }
    @Override
    public int updateArchiveById(String status, Long id) {
    public int updateArchiveById(String status, Long id, String operator) {
        LocalDateTime time = LocalDateTime.now();
        Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
        // 获取当前用户ID
        Long userId = SecurityUtils.getUserId();
        // 可以在这里使用userId进行授权操作
        archiverecordstouserService.deleteArchiverecordstouserByRecordId(id, userId);
        this.baseMapper.updateStatusById(status, id);
        if(operator.equals("退回管理员")||status.equals("录入完成"))
            archiverecordstouserService.deleteArchiverecordstouserByRecordId(id, userId);
        this.baseMapper.updateStatusById(status, id, date);
        return 0;
    }
    @Override
    public int updateStatusByIds(Long[] ids) {
        for(Long id : ids)
            this.baseMapper.updateStatusById("录入完成",id);
        LocalDateTime time = LocalDateTime.now();
        Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
        for(Long id : ids) {
            // 获取当前用户ID,收回授权
            Long userId = SecurityUtils.getUserId();
            archiverecordstouserService.deleteArchiverecordstouserByRecordId(id, userId);
            this.baseMapper.updateStatusById("录入完成", id, date);
        }
        return 0;
    }
@@ -405,21 +459,30 @@
    @Override
    public AjaxResult mySave(ArchiveRecords archiveRecords) {
        // 检查是否有重复数据插入
        System.out.println(archiveRecords.getRecordId()+"aaaaaaaaaaaaaaaaa");
        if(archiveRecords.getRecordId()==null||StringUtils.isEmpty(archiveRecords.getRecordId()))
            throw new RuntimeException("档案号不能为空!");
        LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>();
        lqw.eq(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId,archiveRecords.getRecordId());
        List<ArchiveRecords> list = list(lqw);
        if (list.size() > 0) {
          //  throw new RuntimeException("请勿新增重复数据");
            //如果有重复数据,则根据recordId进行数据修改
        Long userid = SecurityUtils.getUserId();
        if (!list.isEmpty()&&userid!=1) {
           // throw new RuntimeException("请勿新增重复数据");
            //如果有重复数据,则根据recordId进行数据修改sele
         //   if()
//
                this.baseMapper.update(archiveRecords, lqw);
                return AjaxResult.success();
        }
        else if(!list.isEmpty())
        {
             throw new RuntimeException("请勿新增重复数据");
        }
        else {
        Long userid = SecurityUtils.getUserId();
        if(userid==1) {
            if (save(archiveRecords)) {
                return AjaxResult.success();
@@ -427,8 +490,8 @@
                return AjaxResult.error();
            }
        }
             else
            return AjaxResult.error("档案号不存在!");
       else
            return AjaxResult.error("不是管理员,不能新增记录!");
        }
    }