|  |  |  | @ -5,6 +5,7 @@ import cn.estsh.i3plus.pojo.base.bean.ListPager; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.common.Pager; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.common.PagerHelper; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.platform.bean.Organize; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.platform.bean.Position; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.platform.repository.PositionRepository; | 
		
	
		
			
				|  |  |  |  | import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack; | 
		
	
	
		
			
				
					|  |  |  | @ -26,30 +27,59 @@ import java.util.List; | 
		
	
		
			
				|  |  |  |  |  * @Modify : | 
		
	
		
			
				|  |  |  |  |  **/ | 
		
	
		
			
				|  |  |  |  | @Service | 
		
	
		
			
				|  |  |  |  | public class PositionServiceImpl implements IPositionService { | 
		
	
		
			
				|  |  |  |  |     public static final Logger LOGGER = LoggerFactory.getLogger(PositionServiceImpl.class); | 
		
	
		
			
				|  |  |  |  | public class PositionService implements IPositionService { | 
		
	
		
			
				|  |  |  |  |     public static final Logger LOGGER = LoggerFactory.getLogger(PositionService.class); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Autowired | 
		
	
		
			
				|  |  |  |  |     private PositionRepository positionRDao; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Override | 
		
	
		
			
				|  |  |  |  |     public Position insertPosition(Position position) { | 
		
	
		
			
				|  |  |  |  |         // 查询父级岗位名称
 | 
		
	
		
			
				|  |  |  |  |         if (position.getParentId() != null && position.getParentId() > 0) { | 
		
	
		
			
				|  |  |  |  |             LOGGER.info("岗位信息 POSITION parentId:{}", position.getParentId()); | 
		
	
		
			
				|  |  |  |  |         LOGGER.info("岗位信息 POSITION position:{}", position); | 
		
	
		
			
				|  |  |  |  |         // CODE 唯一校验
 | 
		
	
		
			
				|  |  |  |  |         long count = positionRDao.findByPropertyCount("positionCode", position.getPositionCode()); | 
		
	
		
			
				|  |  |  |  |         if(count > 0){ | 
		
	
		
			
				|  |  |  |  |             // 查询父级岗位名称
 | 
		
	
		
			
				|  |  |  |  |             if (position.getParentId() != null && position.getParentId() > 0) { | 
		
	
		
			
				|  |  |  |  |                 LOGGER.info("岗位信息 POSITION parentId:{}", position.getParentId()); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |                 Position parentPosition = positionRDao.getById(position.getParentId()); | 
		
	
		
			
				|  |  |  |  |                 ValidatorBean.checkNotNull(parentPosition); | 
		
	
		
			
				|  |  |  |  |                 position.setRedParentName(parentPosition.getName()); | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             Position parentPosition = positionRDao.getById(position.getParentId()); | 
		
	
		
			
				|  |  |  |  |             ValidatorBean.checkNotNull(parentPosition); | 
		
	
		
			
				|  |  |  |  |             position.setRedParentName(parentPosition.getName()); | 
		
	
		
			
				|  |  |  |  |             // 添加岗位
 | 
		
	
		
			
				|  |  |  |  |             LOGGER.info("岗位信息 POSITION position:{}", position); | 
		
	
		
			
				|  |  |  |  |             return positionRDao.insert(position); | 
		
	
		
			
				|  |  |  |  |         }else { | 
		
	
		
			
				|  |  |  |  |             throw ImppExceptionBuilder.newInstance() | 
		
	
		
			
				|  |  |  |  |                     .setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode()) | 
		
	
		
			
				|  |  |  |  |                     .setErrorCode(ImppExceptionEnum.IO_EXCEPTION.getCode()) | 
		
	
		
			
				|  |  |  |  |                     .setErrorDetail("岗位代码已存在") | 
		
	
		
			
				|  |  |  |  |                     .setErrorSolution("请重新输入岗位代码") | 
		
	
		
			
				|  |  |  |  |                     .build(); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         // 添加岗位
 | 
		
	
		
			
				|  |  |  |  |         LOGGER.info("岗位信息 POSITION position:{}", position); | 
		
	
		
			
				|  |  |  |  |         return positionRDao.insert(position); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Override | 
		
	
		
			
				|  |  |  |  |     public void updatePosition(Position position) { | 
		
	
		
			
				|  |  |  |  |         LOGGER.info("岗位信息 POSITION position:{}", position); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         // 唯一校验 CODE 相同 ID 不同 则视为相同
 | 
		
	
		
			
				|  |  |  |  |         List<Position> list = positionRDao.findByProperty("organizeCode", position.getPositionCode()); | 
		
	
		
			
				|  |  |  |  |         if(null != list && list.size() > 0){ | 
		
	
		
			
				|  |  |  |  |             for (Position pos : list) { | 
		
	
		
			
				|  |  |  |  |                 if(!pos.getId().equals(position.getId())){ | 
		
	
		
			
				|  |  |  |  |                     throw ImppExceptionBuilder.newInstance() | 
		
	
		
			
				|  |  |  |  |                             .setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode()) | 
		
	
		
			
				|  |  |  |  |                             .setErrorCode(ImppExceptionEnum.IO_EXCEPTION.getCode()) | 
		
	
		
			
				|  |  |  |  |                             .setErrorDetail("岗位代码已存在") | 
		
	
		
			
				|  |  |  |  |                             .setErrorSolution("请重新输入岗位代码") | 
		
	
		
			
				|  |  |  |  |                             .build(); | 
		
	
		
			
				|  |  |  |  |                 } | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         // 查询父级岗位名称
 | 
		
	
		
			
				|  |  |  |  |         if (position.getParentId() != null  && position.getParentId() > 0) { | 
		
	
		
			
				|  |  |  |  |             LOGGER.info("岗位信息 POSITION parentId:{}", position.getParentId()); | 
		
	
	
		
			
				
					|  |  |  | @ -73,8 +103,8 @@ public class PositionServiceImpl implements IPositionService { | 
		
	
		
			
				|  |  |  |  |             throw ImppExceptionBuilder.newInstance() | 
		
	
		
			
				|  |  |  |  |                     .setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode()) | 
		
	
		
			
				|  |  |  |  |                     .setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode()) | 
		
	
		
			
				|  |  |  |  |                     .setErrorDetail("存在子节点无法删除!") | 
		
	
		
			
				|  |  |  |  |                     .setErrorSolution("请重新操作") | 
		
	
		
			
				|  |  |  |  |                     .setErrorDetail("存在相关岗位信息无法删除!") | 
		
	
		
			
				|  |  |  |  |                     .setErrorSolution("请先删除子集信息在操作") | 
		
	
		
			
				|  |  |  |  |                     .build(); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -85,20 +115,22 @@ public class PositionServiceImpl implements IPositionService { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Override | 
		
	
		
			
				|  |  |  |  |     public void deletePositionByIds(String[] ids) { | 
		
	
		
			
				|  |  |  |  |         LOGGER.info("岗位信息 POSITION ids:{}", ids); | 
		
	
		
			
				|  |  |  |  |         long positionCount = positionRDao.findByHqlWhereCount(CoreHqlPack.packHqlIds("parentId",ids)); | 
		
	
		
			
				|  |  |  |  |         if (positionCount >= 1) { | 
		
	
		
			
				|  |  |  |  |             throw ImppExceptionBuilder.newInstance() | 
		
	
		
			
				|  |  |  |  |                     .setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode()) | 
		
	
		
			
				|  |  |  |  |                     .setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode()) | 
		
	
		
			
				|  |  |  |  |                     .setErrorDetail("存在子节点无法删除!") | 
		
	
		
			
				|  |  |  |  |                     .setErrorSolution("请重新操作") | 
		
	
		
			
				|  |  |  |  |                     .build(); | 
		
	
		
			
				|  |  |  |  |         }else { | 
		
	
		
			
				|  |  |  |  |         // 判断是否有子节点
 | 
		
	
		
			
				|  |  |  |  |         if (positionCount <= 0) { | 
		
	
		
			
				|  |  |  |  |             Long[] array = new Long[ids.length]; | 
		
	
		
			
				|  |  |  |  |             for (int i = 0; i < ids.length; i++) { | 
		
	
		
			
				|  |  |  |  |                 array[i] = Long.parseLong(ids[i]); | 
		
	
		
			
				|  |  |  |  |             } | 
		
	
		
			
				|  |  |  |  |             positionRDao.deleteByIds(array); | 
		
	
		
			
				|  |  |  |  |         }else { | 
		
	
		
			
				|  |  |  |  |             throw ImppExceptionBuilder.newInstance() | 
		
	
		
			
				|  |  |  |  |                     .setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode()) | 
		
	
		
			
				|  |  |  |  |                     .setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode()) | 
		
	
		
			
				|  |  |  |  |                     .setErrorDetail("存在相关岗位信息无法删除!") | 
		
	
		
			
				|  |  |  |  |                     .setErrorSolution("请重新操作") | 
		
	
		
			
				|  |  |  |  |                     .build(); | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -127,12 +159,15 @@ public class PositionServiceImpl implements IPositionService { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Override | 
		
	
		
			
				|  |  |  |  |     public Position getPositionById(String id) { | 
		
	
		
			
				|  |  |  |  |         LOGGER.info("岗位信息 根据Id查询岗位信息 id:{}", id); | 
		
	
		
			
				|  |  |  |  |         LOGGER.info("岗位信息 Position id:{}", id); | 
		
	
		
			
				|  |  |  |  |         return positionRDao.getById(Long.parseLong(id)); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     @Override | 
		
	
		
			
				|  |  |  |  |     public ListPager findPositionByPager(Position position, Pager pager) { | 
		
	
		
			
				|  |  |  |  |         LOGGER.info("岗位信息 Position position", position); | 
		
	
		
			
				|  |  |  |  |         LOGGER.info("岗位信息 Position pager:{}", pager); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         if (position == null) { | 
		
	
		
			
				|  |  |  |  |             pager = PagerHelper.getPager(pager, positionRDao.listCount()); | 
		
	
		
			
				|  |  |  |  |             return new ListPager(positionRDao.listPager(pager),pager); |