| | |
| | | package com.matrix.system.hive.action; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.core.tools.excl.ExcelSheetPO; |
| | | import com.matrix.core.tools.excl.ExcelVersion; |
| | | import com.matrix.system.common.tools.DataAuthUtil; |
| | | import com.matrix.system.common.tools.ResponseHeadUtil; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.hive.action.util.QueryUtil; |
| | | import com.matrix.system.hive.bean.SysCheckInfo; |
| | | import com.matrix.system.hive.bean.SysOrder; |
| | | import com.matrix.system.hive.bean.SysProjServices; |
| | | import com.matrix.system.hive.dao.SysStoreInfoDao; |
| | | import com.matrix.system.hive.plugin.util.DateUtils; |
| | | import com.matrix.system.hive.pojo.StoreInOutRecordVO; |
| | | import com.matrix.system.hive.service.SysOrderService; |
| | | import com.matrix.system.hive.service.SysProjServicesService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.ModelMap; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.net.URLDecoder; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | SysStoreInfoDao storeInfoDao; |
| | | |
| | | @Autowired |
| | | SysOrderService orderService; |
| | | |
| | | @Autowired |
| | | SysProjServicesService projServicesService; |
| | | |
| | | /** |
| | | * 列表显示 |
| | | */ |
| | |
| | | AjaxResult showList(StoreInOutRecordVO inOutRecordVO, PaginationVO pageVo) { |
| | | QueryUtil.setQueryLimitCom(inOutRecordVO); |
| | | List<StoreInOutRecordVO> dataList =storeInfoDao.findStoreInOutRecord(inOutRecordVO,pageVo); |
| | | |
| | | //原始订单号赋值 |
| | | setExtInfo(dataList); |
| | | |
| | | return AjaxResult.buildSuccessInstance(dataList,storeInfoDao.findStoreInOutTotal(inOutRecordVO)); |
| | | } |
| | | |
| | | /** |
| | | * 填充扩展信息 |
| | | * @param dataList |
| | | */ |
| | | private void setExtInfo(List<StoreInOutRecordVO> dataList) { |
| | | List<Long> serviceIds = dataList.stream().map(StoreInOutRecordVO::getServiceId).filter(e -> Objects.nonNull(e)).collect(Collectors.toList()); |
| | | List<Long> orderIds = dataList.stream().map(StoreInOutRecordVO::getOrderId).filter(e -> Objects.nonNull(e)).collect(Collectors.toList()); |
| | | List<SysOrder> orderList = orderService.findByIds(orderIds); |
| | | Map<String, SysOrder> orderMap=new HashMap<>(); |
| | | Map<String, SysProjServices> serviceMap=new HashMap<>(); |
| | | if(CollUtil.isNotEmpty(orderList)){ |
| | | orderMap = orderList.stream().collect(Collectors.toMap(e->String.format("%s_%s",e.getId(),"DD"), Function.identity(), (a, b) -> a)); |
| | | } |
| | | List<SysProjServices> projServicesList = projServicesService.findByIds(serviceIds); |
| | | if(CollUtil.isNotEmpty(projServicesList)){ |
| | | serviceMap= projServicesList.stream().collect(Collectors.toMap(e->String.format("%s_%s",e.getId(),"FWD"), Function.identity(), (a, b) -> a)); |
| | | } |
| | | if(orderMap.size()>0){ |
| | | for (StoreInOutRecordVO e : dataList){ |
| | | if(Objects.nonNull(e.getOrderId())){ |
| | | SysOrder order = orderMap.get(String.format("%s_%s", e.getOrderId(), "DD")); |
| | | if(Objects.nonNull(order)){ |
| | | e.setSourceOrderNo(order.getOrderNo() ); |
| | | e.setVipName(order.getVipName()); |
| | | } |
| | | } |
| | | if(Objects.nonNull(e.getServiceId())){ |
| | | SysProjServices sysProjServices = serviceMap.get(String.format("%s_%s", e.getServiceId(), "FWD")); |
| | | if(Objects.nonNull(sysProjServices)){ |
| | | e.setSourceOrderNo( sysProjServices.getServiceNo()); |
| | | e.setVipName(sysProjServices.getVipName()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | String title = "库存流向明细"; |
| | | orderSheet.setSheetName(title); |
| | | orderSheet.setTitle(title); |
| | | String[] header = {"时间", "产品编码", "商品名称", "库存分类", "出库数量", "出库单价", "出库金额", "单据编号", "单据类型", "库存批次", "操作人", "单据备注", "门店"}; |
| | | String[] header = {"时间", "产品编码", "商品名称", "库存分类", "出库数量", "出库单价", "出库金额", "来源单据", "下单客户", "单据编号", "单据类型", "库存批次", "操作人", "单据备注", "门店"}; |
| | | orderSheet.setHeaders(header); |
| | | |
| | | if (getMe().getShopRole().equals(Dictionary.FLAG_NO_N)) { |
| | | inOutRecordVO.setShopId(getMe().getShopId()); |
| | | } |
| | | List<StoreInOutRecordVO> dataList =storeInfoDao.findStoreInOutRecord(inOutRecordVO,null); |
| | | |
| | | //原始订单号赋值 |
| | | setExtInfo(dataList); |
| | | |
| | | List<List<Object>> list = new ArrayList<>(); |
| | | if (dataList.size() > 0) { |
| | | for (StoreInOutRecordVO item : dataList) { |
| | | List<Object> temp = new ArrayList<>(); |
| | | String strDate = DateUtils.dateToString(item.getCreateTime(), DateUtils.DATE_FORMAT_MM); |
| | | String strDate = DateUtil.dateToString(item.getCreateTime(), DateUtil.DATE_FORMAT_MM); |
| | | temp.add(strDate); |
| | | temp.add(item.getCode()); |
| | | temp.add(item.getName()); |
| | |
| | | temp.add(item.getAmount()); |
| | | temp.add(item.getGoodsPrice()); |
| | | temp.add(item.getTotalPrice()); |
| | | temp.add(item.getSourceOrderNo()); |
| | | temp.add(item.getVipName()); |
| | | temp.add(item.getOrderNo()); |
| | | temp.add(item.getOrderType()); |
| | | temp.add(item.getBatch()); |