|  | @@ -1,12 +1,24 @@
 | 
	
		
			
				|  |  |  package cn.hnthyy.thmz.service.impl.his.yf;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.Utils.DateUtil;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.entity.his.yp.YpBaseYf;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.mapper.his.yf.YfSpecialMarkMapper;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.mapper.his.yp.YpBaseYfMapper;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.mapper.his.yp.YpMzFytjMapper;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.mapper.his.yp.YpZdDictMapper;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.mapper.his.yp.YpZdManufactoryMapper;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.mapper.his.zy.YpZyPatientMapper;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.service.his.yf.YfSpecialMarkService;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.vo.YpZdBaseYfSpecialVo;
 | 
	
		
			
				|  |  | +import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  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;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * @description:药房特殊标志维护
 | 
	
	
		
			
				|  | @@ -18,9 +30,82 @@ public class YfSpecialMarkServiceImpl implements YfSpecialMarkService {
 | 
	
		
			
				|  |  |      @SuppressWarnings("all")
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      YfSpecialMarkMapper yfSpecialMarkMapper;
 | 
	
		
			
				|  |  | +    @SuppressWarnings("all")
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    YpZdDictMapper ypZdDictMapper;
 | 
	
		
			
				|  |  | +    @SuppressWarnings("all")
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    YpBaseYfMapper ypBaseYfMapper;
 | 
	
		
			
				|  |  | +    @SuppressWarnings("all")
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    YpZdManufactoryMapper ypZdManufactoryMapper;
 | 
	
		
			
				|  |  | +    @SuppressWarnings("all")
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    YpZyPatientMapper ypZyPatientMapper;
 | 
	
		
			
				|  |  | +    @SuppressWarnings("all")
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    YpMzFytjMapper ypMzFytjMapper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<YpZdBaseYfSpecialVo> queryYpSpecialMark(String groupNo, String searchText) {
 | 
	
		
			
				|  |  | -        return yfSpecialMarkMapper.selectYpSpecialMark(groupNo, searchText);
 | 
	
		
			
				|  |  | +        List<YpZdBaseYfSpecialVo> ypZdBaseYfSpecialVos = new ArrayList<>();
 | 
	
		
			
				|  |  | +        List<YpZdDict> ypZdDicts = ypZdDictMapper.selectYpBySearchText(searchText);
 | 
	
		
			
				|  |  | +        ypZdDicts.forEach(ypZdDict -> {
 | 
	
		
			
				|  |  | +            YpZdBaseYfSpecialVo ypZdBaseYfSpecialVo = new YpZdBaseYfSpecialVo();
 | 
	
		
			
				|  |  | +            YpBaseYf ypBaseYf = ypBaseYfMapper.selectYpBaseYf(ypZdDict.getCode(), ypZdDict.getSerial(), groupNo);
 | 
	
		
			
				|  |  | +            if(ypBaseYf != null){
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setGroupNo(groupNo);
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setChargeCode(ypBaseYf.getChargeCode());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setSerial(ypBaseYf.getSerial());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setName(ypZdDict.getName());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setClassCode(ypZdDict.getClassCode());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setSpecification(ypZdDict.getSpecification());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setVisibleFlagMz(ypBaseYf.getVisibleFlagMz());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setVisibleFlagZy(ypBaseYf.getVisibleFlagZy());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setStockAmount(ypBaseYf.getStockAmount());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setVisibleFlagStop(ypBaseYf.getVisibleFlagStop());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setStockAmountVirtual2(ypBaseYf.getStockAmountVirtual2());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setOpenVirtual2(ypBaseYf.getOpenVirtual2());
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setPrescriptionLimitDays(ypBaseYf.getPrescriptionLimitDays());
 | 
	
		
			
				|  |  | +                String manufactoryName = ypZdManufactoryMapper.selectYpZdManufactoryByCode(ypZdDict.getManuCode());
 | 
	
		
			
				|  |  | +                if(StringUtils.isNotBlank(manufactoryName)){
 | 
	
		
			
				|  |  | +                    ypZdBaseYfSpecialVo.setManufactoryName(manufactoryName);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                Double largeStockAmount = ypBaseYfMapper.selectLargeStockAmount(ypZdDict.getCode(), groupNo);
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setStockAmountLarge(largeStockAmount);
 | 
	
		
			
				|  |  | +                List<Map<String, Object>> zyList = ypZyPatientMapper.selectLatelyYpZyPatient(ypZdDict.getCode(), ypZdDict.getSerial(), ypZdDict.getPackSize().doubleValue(), groupNo);
 | 
	
		
			
				|  |  | +                List<Map<String, Object>> ypMzFytjs = ypMzFytjMapper.selectLatelyYpMzFytj(ypZdDict.getCode(), ypZdDict.getSerial(), ypZdDict.getPackSize().doubleValue(), groupNo);
 | 
	
		
			
				|  |  | +                zyList.addAll(ypMzFytjs);
 | 
	
		
			
				|  |  | +                int threeDayDosage = 0;
 | 
	
		
			
				|  |  | +                int sevenDayDosage = 0;
 | 
	
		
			
				|  |  | +                int fourteenDayDosage = 0;
 | 
	
		
			
				|  |  | +                int thirtyDayDosage = 0;
 | 
	
		
			
				|  |  | +                for (int i = 0; i < zyList.size(); i++) {
 | 
	
		
			
				|  |  | +                    Map<String, Object> map = zyList.get(i);
 | 
	
		
			
				|  |  | +                    if(DateUtil.differentDaysByMillisecond(DateUtil.pase(map.get("confirm_time").toString(),"yyyy-MM-dd HH:mm:ss"),new Date())
 | 
	
		
			
				|  |  | +                            <=3){
 | 
	
		
			
				|  |  | +                        threeDayDosage+=Double.parseDouble(map.get("quantity").toString());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if(DateUtil.differentDaysByMillisecond(DateUtil.pase(map.get("confirm_time").toString(),"yyyy-MM-dd HH:mm:ss"),new Date())
 | 
	
		
			
				|  |  | +                            <=7){
 | 
	
		
			
				|  |  | +                        sevenDayDosage+=Double.parseDouble(map.get("quantity").toString());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if(DateUtil.differentDaysByMillisecond(DateUtil.pase(map.get("confirm_time").toString(),"yyyy-MM-dd HH:mm:ss"),new Date())
 | 
	
		
			
				|  |  | +                            <=14){
 | 
	
		
			
				|  |  | +                        fourteenDayDosage+=Double.parseDouble(map.get("quantity").toString());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if(DateUtil.differentDaysByMillisecond(DateUtil.pase(map.get("confirm_time").toString(),"yyyy-MM-dd HH:mm:ss"),new Date())
 | 
	
		
			
				|  |  | +                            <=30){
 | 
	
		
			
				|  |  | +                        thirtyDayDosage+=Double.parseDouble(map.get("quantity").toString());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setThreeDayDosage(threeDayDosage);
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setSevenDayDosage(sevenDayDosage);
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setFourteenDayDosage(fourteenDayDosage);
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVo.setThirtyDayDosage(thirtyDayDosage);
 | 
	
		
			
				|  |  | +                ypZdBaseYfSpecialVos.add(ypZdBaseYfSpecialVo);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        return ypZdBaseYfSpecialVos;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |