package com.ruoyi.demo.service.impl; import com.ruoyi.demo.entity.WdOpclose; import com.ruoyi.demo.entity.vo.AddStatusVo; import com.ruoyi.demo.entity.vo.WdOpcloseVo; import com.ruoyi.demo.mapper.WdInfoMapper; import com.ruoyi.demo.mapper.WdOpcloseDao; import com.ruoyi.demo.service.WdInfoService; import com.ruoyi.demo.utils.CategoryUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; @Service public class WdInfoServiceImpl implements WdInfoService { @Autowired CategoryUtil categoryUtil; @Autowired WdInfoMapper wdInfoMapper; @Autowired WdOpcloseDao wdOpcloseDao; @Override public List searchAddStatus(List addrCodes, List typeCodes) { categoryUtil.setWdTypeMap(); List addrs = new ArrayList<>(); List times = new ArrayList<>(); for (int i = 0; i < 12; i++){ times.add(LocalDateTime.now(ZoneId.of("Asia/Shanghai")).plusMonths(-i).format(DateTimeFormatter.ofPattern("yyyy-MM"))); } if (addrCodes != null){ for (String s : addrCodes){ List allOtherAddrCode = categoryUtil.getAllOtherAddrCode(s); addrs.addAll(allOtherAddrCode); } }else{ addrs = null; } List addStatusVos = wdInfoMapper.searchAddStatusByMulti(times, addrs, typeCodes); for (AddStatusVo vo : addStatusVos){ vo.setTypeName(categoryUtil.wdTypeMap.get(vo.getTypeCode())); } return addStatusVos; } @Override public List searchWdOpcloses(List addrCodes, List wdTypeCodes) { categoryUtil.setAddrMap(); List vos = new ArrayList<>(); if (addrCodes != null){ for (String s : addrCodes){ WdOpclose opclose = wdOpcloseDao.selectListByAddrCodeAndWdTypeCodes(categoryUtil.whatis(s), wdTypeCodes, LocalDateTime.now(ZoneId.of("Asia/Shanghai")).plusMonths(-1)); if (opclose != null){ WdOpcloseVo vo = new WdOpcloseVo(s,opclose); vo.setAddrName(categoryUtil.addrMap.get(s)); vos.add(vo); } } return vos; } return vos; } // @Override // public List searchAddrTypeDistribution(List addrCodes, List typeCodes) { // List acodes = new ArrayList<>(); // for (String s : addrCodes){ // List allOtherAddrCode = getAllOtherAddrCode(s); // acodes.addAll(allOtherAddrCode); // } // List list = wdInfoMapper.searchAddrDisByMulti(acodes, typeCodes); // setTypeMap(); // setAddrMap(); // for (WdAddrTypeDistribution wd : list){ // wd.setTypeName(typeMap.get(wd.getTypeCode())); // wd.setAddrName(addrMap.get(wd.getAddrCode())); // } // return list; // } // @Override // public List searchWdTypeDistribution(List addrCodes, List typeCodes) { // List list = wdInfoMapper.searchWdTypeDisByMulti(addrCodes, typeCodes); // setAddrMap(); // setWdTypeMap(); // for (WdAddrTypeDistribution wd : list){ // wd.setAddrName(addrMap.get(wd.getAddrCode())); // wd.setTypeName(wdTypeMap.get(wd.getTypeCode())); // } // return list; // } // @Override // public List searchWdTotal() { // List list = wdInfoMapper.searchWdTotal(); // setWdTypeMap(); // for (WdAddrTypeDistribution wd : list){ // wd.setTypeName(wdTypeMap.get(wd.getTypeCode())); // } // return list; // } }