|  |  |  | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.controller.AbstractBaseController; | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.Node; | 
|---|
|  |  |  | import com.zy.asrs.entity.Tag; | 
|---|
|  |  |  | import com.zy.asrs.service.NodeService; | 
|---|
|  |  |  | import com.zy.asrs.service.TagService; | 
|---|
|  |  |  | import com.zy.system.entity.User; | 
|---|
|  |  |  | import com.zy.system.entity.UserLogin; | 
|---|
|  |  |  | import com.zy.system.service.UserLoginService; | 
|---|
|  |  |  | import com.zy.system.service.UserService; | 
|---|
|  |  |  | import io.swagger.annotations.ApiModelProperty; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  | protected HttpServletRequest request; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserService userService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TagService tagService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NodeService nodeService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserLoginService userLoginService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected Node getOriginNode(){ | 
|---|
|  |  |  | Node node = nodeService.getTop(); | 
|---|
|  |  |  | if (node == null) { | 
|---|
|  |  |  | throw new CoolException("库区数据错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return node; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected Long getHostId(){ | 
|---|
|  |  |  | if (getUserId() == 9527) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | User user = getUser(); | 
|---|
|  |  |  | if (user.getRoleId() == 1) { | 
|---|
|  |  |  | String hostId = String.valueOf(request.getAttribute("hostId")); | 
|---|
|  |  |  | if (Cools.isEmpty(hostId)) { | 
|---|
|  |  |  | UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("user_id", user.getId())); | 
|---|
|  |  |  | if (userLogin != null) { | 
|---|
|  |  |  | return userLogin.getHostId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return Long.parseLong(hostId); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return user.getHostId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected Long getUserId(){ | 
|---|
|  |  |  | return Long.parseLong(String.valueOf(request.getAttribute("userId"))); | 
|---|
|  |  |  | 
|---|
|  |  |  | return ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected Tag getOriginTag(){ | 
|---|
|  |  |  | return tagService.getTop(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected <T> void hostEq(EntityWrapper<T> wrapper){ | 
|---|
|  |  |  | Long hostId = getHostId(); | 
|---|
|  |  |  | if (hostId != null) { | 
|---|
|  |  |  | wrapper.eq("host_id", hostId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分页组装 | 
|---|
|  |  |  | * @param pageNumber | 
|---|
|  |  |  | 
|---|
|  |  |  | // 全字段模糊搜索 todo | 
|---|
|  |  |  | if (!Cools.isEmpty(map.get("condition"))) { | 
|---|
|  |  |  | Set<String> columns = new HashSet<>(); | 
|---|
|  |  |  | for (Field field :Cools.getAllFields(cls)){ | 
|---|
|  |  |  | for (Field field : Cools.getAllFields(cls)){ | 
|---|
|  |  |  | if (Modifier.isFinal(field.getModifiers()) | 
|---|
|  |  |  | || Modifier.isStatic(field.getModifiers()) | 
|---|
|  |  |  | || Modifier.isTransient(field.getModifiers())){ | 
|---|