| | |
| | | package com.mzl.flower.service.impl.statisticsAnalysis; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.mzl.flower.base.cache.DictCacheClient; |
| | | import com.mzl.flower.dto.request.statisticAnalysis.FlowerMaterialDTO; |
| | | import com.mzl.flower.dto.response.report.OrderReportResultVO; |
| | | import com.mzl.flower.dto.response.statisticAnalysis.FlowerMaterialStaticVO; |
| | | import com.mzl.flower.dto.response.statisticAnalysis.FlowerMaterialVO; |
| | | import com.mzl.flower.mapper.statisticsAnalysis.FlowerMaterialMapper; |
| | | import com.mzl.flower.service.BaseService; |
| | | import com.mzl.flower.service.statisticsAnalysis.StatisticAnalysisService; |
| | | import com.mzl.flower.utils.ExcelExportUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class StatisticAnalysisServiceImpl implements StatisticAnalysisService { |
| | | public class StatisticAnalysisServiceImpl extends BaseService implements StatisticAnalysisService { |
| | | |
| | | @Autowired |
| | | private DictCacheClient dictCacheClient; |
| | | |
| | | @Autowired |
| | | private FlowerMaterialMapper flowerMaterialMapper; |
| | | |
| | | @Override |
| | | public Page<FlowerMaterialVO> getFlowerMaterialPage(Page page, FlowerMaterialDTO dto) { |
| | | return null; |
| | | |
| | | Page<FlowerMaterialVO> result=flowerMaterialMapper.getFlowerMaterialPage(page, dto); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public FlowerMaterialStaticVO getFlowerMaterialStatis(FlowerMaterialDTO dto) { |
| | | return null; |
| | | List<FlowerMaterialStaticVO> list= flowerMaterialMapper.getFlowerMaterialStatis(dto); |
| | | if(!CollectionUtils.isEmpty(list)){ |
| | | return list.get(0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void exportFlowerMaterialSales(HttpServletResponse response, FlowerMaterialDTO dto) { |
| | | List<FlowerMaterialVO> list=flowerMaterialMapper.getFlowerMaterialList(dto); |
| | | |
| | | String[] rowsName = new String[]{ |
| | | "序号" |
| | | ,"供应商ID", "供应商名称","注册手机号","联系方式","所属集货站","品类","商品名称","等级","商品规格","价格","库存","状态",}; |
| | | List<Object[]> dataList = new ArrayList<>(); |
| | | int sn = 1; |
| | | for (FlowerMaterialVO o : list) { |
| | | Object[] objs = new Object[rowsName.length]; |
| | | int a = 0; |
| | | objs[a++] = sn; // 序号 |
| | | objs[a++] = o.getSupplierId(); // 供应商ID |
| | | objs[a++] = o.getSupplierName(); // 供应商名称 |
| | | objs[a++] = o.getLoginName(); // 注册手机号 |
| | | objs[a++] = o.getContactTel(); // 联系方式" |
| | | objs[a++] = o.getStationName(); // 所属集货站 |
| | | objs[a++] = o.getCategoryName(); // 品类 |
| | | objs[a++] = o.getFlowerName(); //商品名称 |
| | | // String dictValue = dictCacheClient.getDict("FLOWER_LEVEL", o.getFlowerLevel()); |
| | | // objs[a++] = dictValue; //等级 |
| | | objs[a++] = o.getFlowerLevelStr(); //等级 |
| | | objs[a++] = o.getFlowerUnit(); //商品规格 |
| | | objs[a++] = o.getFlowerPrice();//价格 |
| | | objs[a++] = o.getFlowerStock();//库存 |
| | | // String dictValueStatus = dictCacheClient.getDict("FLOWER_STATUS", o.getFlowerStatus()); |
| | | // objs[a++] =dictValueStatus; |
| | | objs[a++] = o.getFlowerStatusStr(); // 状态 |
| | | |
| | | dataList.add(objs); |
| | | sn++; |
| | | } |
| | | |
| | | ExcelExportUtil excelExportUtil = new ExcelExportUtil("花材统计报表", rowsName, dataList, response); |
| | | try { |
| | | response.addHeader("filename", URLEncoder.encode("花材统计报表.xls", "UTF-8")); |
| | | response.addHeader("Access-Control-Expose-Headers", "filename"); |
| | | excelExportUtil.export(); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |