|  | @@ -3,7 +3,9 @@ package com.xunmei.core.safetybook.service.impl;
 | 
	
		
			
				|  |  |  import java.util.Date;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import cn.hutool.core.util.ObjectUtil;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.constant.SecurityConstants;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.utils.DateUtils;
 | 
	
		
			
				|  |  |  import com.xunmei.common.security.utils.SecurityUtils;
 | 
	
	
		
			
				|  | @@ -15,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.util.Arrays;
 | 
	
		
			
				|  |  | +import java.util.Optional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
	
		
			
				|  | @@ -22,6 +25,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
	
		
			
				|  |  |  import com.xunmei.common.core.web.page.TableDataInfo;
 | 
	
		
			
				|  |  |  import com.xunmei.core.safetybook.mapper.CoreSafetyBookNewMapper;
 | 
	
		
			
				|  |  |  import com.xunmei.core.safetybook.service.ICoreSafetyBookNewService;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 【请填写功能名称】Service业务层处理
 | 
	
	
		
			
				|  | @@ -40,27 +44,11 @@ public class CoreSafetyBookNewServiceImpl extends ServiceImpl<CoreSafetyBookNewM
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public TableDataInfo<CoreSafetyBookNew> selectPage(CoreSafetyBookNew coreSafetyBookNew) {
 | 
	
		
			
				|  |  | -        //未删除
 | 
	
		
			
				|  |  | -        coreSafetyBookNew.setDeleted(0L);
 | 
	
		
			
				|  |  | -        Page<CoreSafetyBookNew> page;
 | 
	
		
			
				|  |  | -        //分页
 | 
	
		
			
				|  |  | -        if (coreSafetyBookNew.getPageNum() != null && coreSafetyBookNew.getPageSize() != null) {
 | 
	
		
			
				|  |  | -            page = new Page<>(coreSafetyBookNew.getPageNum(), coreSafetyBookNew.getPageSize());
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            page = new Page<>();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        //查询条件
 | 
	
		
			
				|  |  | -        QueryWrapper<CoreSafetyBookNew> query = new QueryWrapper<>(coreSafetyBookNew);
 | 
	
		
			
				|  |  | -        SysOrg org = orgService.selectOrgById(coreSafetyBookNew.getPartyBOrg() ,SecurityConstants.INNER);
 | 
	
		
			
				|  |  | -        if (org != null) {
 | 
	
		
			
				|  |  | -            coreSafetyBookNew.setSelectOrgPath(org.getPath());
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          //获取数据
 | 
	
		
			
				|  |  | -        page = coreSafetyBookNewMapper.selectSafetyBookNewPage(page, coreSafetyBookNew);
 | 
	
		
			
				|  |  | +        Page<CoreSafetyBookNew> page = coreSafetyBookNewMapper.selectSafetyBookNewPage(dealPageParam(coreSafetyBookNew), coreSafetyBookNew);
 | 
	
		
			
				|  |  |          page.getRecords().forEach(e -> {
 | 
	
		
			
				|  |  |              e.setFiles(coreSafetyBookBookFilesMapper.selecVotList(e.getId()));
 | 
	
		
			
				|  |  | -            e.setPartyAOrgName(!e.getType().equals(2L) ? e.getPartyAOrgName() : orgService.selectOrgById(e.getPartyAOrg(), SecurityConstants.INNER).getShortName());
 | 
	
		
			
				|  |  | -            e.setPartyBOrgName(!e.getType().equals(2L) ? orgService.selectOrgById(e.getPartyBOrg(), SecurityConstants.INNER).getShortName():e.getPartyBOrgName());
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //抓换为TableDataInfo适配前端
 | 
	
	
		
			
				|  | @@ -69,6 +57,27 @@ public class CoreSafetyBookNewServiceImpl extends ServiceImpl<CoreSafetyBookNewM
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private Page<CoreSafetyBookNew> dealPageParam(CoreSafetyBookNew coreSafetyBookNew) {
 | 
	
		
			
				|  |  | +        //未删除
 | 
	
		
			
				|  |  | +        coreSafetyBookNew.setDeleted(0L);
 | 
	
		
			
				|  |  | +        if (ObjectUtil.isNull(coreSafetyBookNew.getPageNum())) {
 | 
	
		
			
				|  |  | +            coreSafetyBookNew.setPageNum(1L);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (ObjectUtil.isNull(coreSafetyBookNew.getPageSize())) {
 | 
	
		
			
				|  |  | +            coreSafetyBookNew.setPageNum(10L);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        final Page<CoreSafetyBookNew> page = new Page<>(coreSafetyBookNew.getPageNum(), coreSafetyBookNew.getPageSize());
 | 
	
		
			
				|  |  | +        if (ObjectUtil.isEmpty(coreSafetyBookNew.getPartyBOrg())){
 | 
	
		
			
				|  |  | +            throw new RuntimeException("请选择具体机构查询!");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //查询条件
 | 
	
		
			
				|  |  | +        SysOrg org = orgService.selectOrgById(coreSafetyBookNew.getPartyBOrg(), SecurityConstants.INNER);
 | 
	
		
			
				|  |  | +        if (org != null) {
 | 
	
		
			
				|  |  | +            coreSafetyBookNew.setSelectOrgPath(org.getPath());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return page;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询【请填写功能名称】
 | 
	
	
		
			
				|  | @@ -80,7 +89,7 @@ public class CoreSafetyBookNewServiceImpl extends ServiceImpl<CoreSafetyBookNewM
 | 
	
		
			
				|  |  |      public CoreSafetyBookNew selectCoreSafetyBookNewById(Long id) {
 | 
	
		
			
				|  |  |          CoreSafetyBookNew coreSafetyBookNew = coreSafetyBookNewMapper.selectSafetyBookById(id);
 | 
	
		
			
				|  |  |          coreSafetyBookNew.setPartyAOrgName(!coreSafetyBookNew.getType().equals(2L) ? coreSafetyBookNew.getPartyAOrgName() : orgService.selectOrgById(coreSafetyBookNew.getPartyAOrg(), SecurityConstants.INNER).getShortName());
 | 
	
		
			
				|  |  | -        coreSafetyBookNew.setPartyBOrgName(!coreSafetyBookNew.getType().equals(2L) ? orgService.selectOrgById(coreSafetyBookNew.getPartyBOrg(), SecurityConstants.INNER).getShortName():coreSafetyBookNew.getPartyBOrgName());
 | 
	
		
			
				|  |  | +        coreSafetyBookNew.setPartyBOrgName(!coreSafetyBookNew.getType().equals(2L) ? orgService.selectOrgById(coreSafetyBookNew.getPartyBOrg(), SecurityConstants.INNER).getShortName() : coreSafetyBookNew.getPartyBOrgName());
 | 
	
		
			
				|  |  |          coreSafetyBookNew.setFiles(coreSafetyBookBookFilesMapper.selecVotList(id));
 | 
	
		
			
				|  |  |          return coreSafetyBookNew;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -103,7 +112,9 @@ public class CoreSafetyBookNewServiceImpl extends ServiceImpl<CoreSafetyBookNewM
 | 
	
		
			
				|  |  |       * @return 结果
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public int insertCoreSafetyBookNew(CoreSafetyBookNew coreSafetyBookNew) {
 | 
	
		
			
				|  |  | +        dealOrgName(coreSafetyBookNew);
 | 
	
		
			
				|  |  |          //编辑
 | 
	
		
			
				|  |  |          if (coreSafetyBookNew.getId() != null) {
 | 
	
		
			
				|  |  |              coreSafetyBookNew.setUpdateTime(new Date());
 | 
	
	
		
			
				|  | @@ -128,6 +139,17 @@ public class CoreSafetyBookNewServiceImpl extends ServiceImpl<CoreSafetyBookNewM
 | 
	
		
			
				|  |  |          return 1;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private void dealOrgName(CoreSafetyBookNew coreSafetyBookNew) {
 | 
	
		
			
				|  |  | +        if (ObjectUtil.isNotEmpty(coreSafetyBookNew.getPartyAOrg())) {
 | 
	
		
			
				|  |  | +            final SysOrg sysOrg = orgService.selectOrgById(coreSafetyBookNew.getPartyAOrg(), SecurityConstants.INNER);
 | 
	
		
			
				|  |  | +            Optional.of(sysOrg).ifPresent(org -> coreSafetyBookNew.setPartyAOrgName(org.getShortName()));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (ObjectUtil.isNotEmpty(coreSafetyBookNew.getPartyBOrg())) {
 | 
	
		
			
				|  |  | +            final SysOrg sysOrg = orgService.selectOrgById(coreSafetyBookNew.getPartyBOrg(), SecurityConstants.INNER);
 | 
	
		
			
				|  |  | +            Optional.of(sysOrg).ifPresent(org -> coreSafetyBookNew.setPartyBOrgName(org.getShortName()));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 修改【请填写功能名称】
 | 
	
		
			
				|  |  |       *
 |