package com.unis.base.server.service.impl;

import com.github.pagehelper.PageInfo;
import com.unis.base.common.vo.*;
import com.unis.base.server.domain.DYpxxDomain;
import com.unis.base.server.entity.ClhxyjbgtzDO;
import com.unis.base.server.entity.FqwxhxpcszclyclqkbDO;
import com.unis.base.server.entity.WxhxphjglpcjbbDO;
import com.unis.base.server.service.DYpxxService;
import com.unis.common.utils.LsBeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author ：yangshengjie
 * @date ：Created in 2019/9/20 9:29
 * @Title DYpxxServiceImpl
 * @ProjectName  药剂信息服务实现层
 */
@Service
public class DYpxxServiceImpl implements DYpxxService {

    @Autowired
    private DYpxxDomain dYpxxDomain;

    /**
     * create by: yangshengjie
     * create time: 2019/9/20 9:32
     *
     * @return List
     * @Param: DYpxxQueryVO
     */
    @Override
    public PageInfo<DYpxxVO> findDYpxxList(DYpxxQueryVO dYpxxQueryVO, Integer pageNum, Integer pageSize) {
        return dYpxxDomain.findYpxxList(dYpxxQueryVO,pageNum,pageSize);
    }

	/**
	 * gengxinbazt
	 */
	@Override
	public Integer updateMedicineinfoStatus(DYpxxHisVO dYpxxHisVO) {
		return dYpxxDomain.updateMedicineinfoStatus(dYpxxHisVO);
	}

	/**
	 * 
	 */
	@Override
	public DYpxxVO getDYpxxInfoByLsId(String ypId) {
		return dYpxxDomain.getDYpxxInfoByLsId(ypId);
	}
	@Override
	public Map<String, Object> findReportsInfoList(KdBaseInfoVO VO, Integer page, Integer size ) throws Exception{
		return dYpxxDomain.findReportsInfoList(VO, page, size);
	}
	@Override
	public KdBaseInfoVO findClhxyjbgtzByKddm(String id) throws Exception{
		KdBaseInfoVO resVO = LsBeanUtils.copyProperties(dYpxxDomain.findKdBaseInfoById(id), KdBaseInfoVO.class);
		List<ClhxyjbgtzVO> res = new ArrayList<ClhxyjbgtzVO>();
		LsBeanUtils.copyCollection(dYpxxDomain.findClhxyjbgtzByKddm(id), res, ClhxyjbgtzVO.class);
		resVO.setClhxyjbgtzVOList(res);
		return resVO;
	};
	@Override
	public KdBaseInfoVO findFqwxhxpcszclyclqkbByKddm(String id) throws Exception{
		KdBaseInfoVO resVO = LsBeanUtils.copyProperties(dYpxxDomain.findKdBaseInfoById(id), KdBaseInfoVO.class);
		List<FqwxhxpcszclyclqkbVO> res =  new ArrayList<FqwxhxpcszclyclqkbVO>();
		LsBeanUtils.copyCollection(dYpxxDomain.findFqwxhxpcszclyclqkbByKddm(id), res, FqwxhxpcszclyclqkbVO.class);
		resVO.setFqwxhxpcszclyclqkbVOList(res);
		return resVO;
	};
	@Override
	public KdBaseInfoVO findWxhxphjglpcjbbByKdmc(String id) throws Exception{
		KdBaseInfoVO resVO = LsBeanUtils.copyProperties(dYpxxDomain.findKdBaseInfoById(id), KdBaseInfoVO.class);
		List<WxhxphjglpcjbbVO> res  = new ArrayList<WxhxphjglpcjbbVO>();
		LsBeanUtils.copyCollection(dYpxxDomain.findWxhxphjglpcjbbByKdmc(id), res, WxhxphjglpcjbbVO.class);
		resVO.setWxhxphjglpcjbbVOList(res);
		return resVO;
	}
	@Override
	public List<WxhxphjglpcjbbVO> findWxhxphjglpcjbbApp(KdBaseInfoVO vo) throws Exception{
		KdBaseInfoVO resVO = LsBeanUtils.copyProperties(dYpxxDomain.findWxhxphjglpcjbbApp(vo), KdBaseInfoVO.class);
		List<WxhxphjglpcjbbVO> res  = new ArrayList<WxhxphjglpcjbbVO>();
		if(resVO == null ){
			return null;
		}
		List<WxhxphjglpcjbbDO> s = dYpxxDomain.findWxhxphjglpcjbbByKdmc(resVO.getId());
		if (s == null) {
			return null;
		}
		LsBeanUtils.copyCollection(s, res, WxhxphjglpcjbbVO.class);
		resVO.setWxhxphjglpcjbbVOList(res);
		return res;
	}
}
