/***文档注释***********************************************
 * 作者               :                   易鑫
 * 创建日期      :                   2018.2.5
 * 描述               :                   树型数据生成
 * 注意事项      :                   无
 * 遗留BUG :                   无
 * 修改日期      :                   2016.04.11
 * 修改人员      :                   易鑫
 * 修改内容      :                   增加App端调用方法
***********************************************************/

package market.Com.impl;

import java.util.List;

import market.Com.mapper.TreeNodeMapper;
import market.Com.pb.TreeNodeHelper;
import market.Com.service.TreeNodeService;
import market.Com.vo.CommonPage;
import market.Com.vo.ElementUITree;
import market.Com.vo.ResultModel;
import market.Com.vo.TreeNode;

import com.hnshituo.basic.service.impl.BaseServiceImpl;
import com.hnshituo.basic.spring.remoting.annotation.RemoteService;

@RemoteService(path="TreeNodeService")
public class TreeNodeServiceImpl extends BaseServiceImpl<TreeNode,Object> implements TreeNodeService {
	/**
	 * 基础数据树查询
	 * @param sum
	 * memo1 为 父节点值
	 * memo2 为 valid_flag值 1为有效 0无效
	 * @return
	 */
	public ResultModel findComBaseInfoTree(CommonPage<TreeNode> sum){
		ResultModel rm=new ResultModel();
		try{
			List<TreeNode> ltn=this.getMapper(TreeNodeMapper.class).findComBaseInfo(sum.getMemo1(),sum.getMemo2());
			TreeNodeHelper th=new TreeNodeHelper();
			List<TreeNode> lt = th.GetTreeJsonByList(ltn, sum.getMemo1());
			rm.setData(lt);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("服务端异常，获取数据失败!");
		}
		return rm;
	}
	
	/**
	 * 销售区域
	 * memo1 为 父节点值
	 * memo2 为 valid_flag值 1为有效 0无效
	 * */
	public ResultModel findSlmBaseSaleareaInfoTree(CommonPage<TreeNode> sum){
		ResultModel rm=new ResultModel();
		try{
			List<TreeNode> ltn=this.getMapper(TreeNodeMapper.class).findSlmBaseSaleareaInfo(sum.getMemo1(),sum.getMemo2());
			TreeNodeHelper th=new TreeNodeHelper();
			List<TreeNode> lt = th.GetTreeJsonByList(ltn, sum.getMemo1());
			rm.setData(lt);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("服务端异常，获取数据失败!");
		}
		return rm;
	}
	
	/**
	 * 行政区域
	 * memo1 为 父节点值
	 * memo2 为 valid_flag值 1为有效 0无效
	 * */
	public ResultModel findSlmBaseRegionTree(CommonPage<TreeNode> sum){
		ResultModel rm=new ResultModel();
		try{
			List<TreeNode> ltn=this.getMapper(TreeNodeMapper.class).findSlmBaseRegion(sum.getMemo1(),sum.getMemo2());
			TreeNodeHelper th=new TreeNodeHelper();
			List<TreeNode> lt = th.GetTreeJsonByList(ltn, sum.getMemo1());
			rm.setData(lt);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("服务端异常，获取数据失败!");
		}
		return rm;
	}
	
	/**
	 * 组织机构树
	 * memo1 为 部门编号
	 * */
	public ResultModel findSlmCustomerOrgTree(CommonPage<TreeNode> sum){
		ResultModel rm=new ResultModel();
		try{
			List<TreeNode> ltn=this.getMapper(TreeNodeMapper.class).findSlmCustomerOrg(sum.getMemo1());
			TreeNodeHelper th=new TreeNodeHelper();
			List<TreeNode> lt = th.GetTreeJsonByList(ltn, sum.getMemo1());
			rm.setData(lt);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("服务端异常，获取数据失败!");
		}
		return rm;
	}
	
	/**
	 * 仓库区域结构树
	 * memo1为父节点值
	 * memo2valid_flag值 1为有效 0无效
	 * */
	public ResultModel findYdmBaseButtressConfigTree(CommonPage<TreeNode> sum){
		ResultModel rm=new ResultModel();
		try{
			List<TreeNode> ltn=this.getMapper(TreeNodeMapper.class).findYdmBaseButtressConfig(sum.getMemo1(),sum.getMemo2(),sum.getMemo3());
			TreeNodeHelper th=new TreeNodeHelper();
			List<TreeNode> lt = th.GetTreeJsonByList(ltn, sum.getMemo3());
			rm.setData(lt);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("服务端异常，获取数据失败!");
		}
		return rm;
	}
	
	/**
	 * 单位结构树
	 * memo1为父节点值
	 * */
	public ResultModel findCoreAuthDepartmentTree(CommonPage<TreeNode> sum){
		ResultModel rm=new ResultModel();
		try{
			List<TreeNode> ltn=this.getMapper(TreeNodeMapper.class).findCoreAuthDepartmentTree(sum.getMemo1());
			TreeNodeHelper th=new TreeNodeHelper();
			List<TreeNode> lt = th.GetTreeJsonByList(ltn, sum.getMemo1());
			rm.setData(lt);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("服务端异常，获取数据失败!");
		}
		return rm;
	}
	
	/**
	 * 物料属性配置表
	 * memo1为父节点值
	 * */
	public ResultModel findPurMatAttrsTree(CommonPage<TreeNode> sum){
		ResultModel rm=new ResultModel();
		try{
			List<TreeNode> ltn=this.getMapper(TreeNodeMapper.class).findPurMatAttrsTree(sum.getMemo1(),sum.getMemo2());
			TreeNodeHelper th=new TreeNodeHelper();
			List<TreeNode> lt = th.GetTreeJsonByList(ltn, sum.getMemo1());
			rm.setData(lt);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("服务端异常，获取数据失败!");
		}
		return rm;
	}
	
	/**
	 * 物料分类配置表
	 * memo1为父节点值
	 * */
	public ResultModel findPurMatClassTree(CommonPage<TreeNode> sum){
		ResultModel rm=new ResultModel();
		try{
			List<TreeNode> ltn=this.getMapper(TreeNodeMapper.class).findPurMatClassTree(sum.getMemo1(),sum.getMemo2());
			TreeNodeHelper th=new TreeNodeHelper();
			List<TreeNode> lt = th.GetTreeJsonByList(ltn, sum.getMemo1());
			rm.setData(lt);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("服务端异常，获取数据失败!");
		}
		return rm;
	}
	
	/**
	 * 获取产品信息
	 * @return
	 */
	public ResultModel findProductTree(){
		ResultModel rm=new ResultModel();
		try{
			List<ElementUITree> ltn=this.getMapper(TreeNodeMapper.class).findProductTree();
			TreeNodeHelper th=new TreeNodeHelper();
			List<ElementUITree> lt = th.GetProductTree(ltn, "4049");
			rm.setData(lt);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("服务端异常，获取数据失败!");
		}
		return rm;
	}
}
