|
@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.sun.org.apache.bcel.internal.generic.NEW; |
|
|
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
import com.yxt.common.core.result.ResultBean; |
|
@ -19,7 +18,6 @@ import com.yxt.supervise.gf.shanhai.resp.BaseResponseListObj; |
|
|
import org.apache.poi.ss.usermodel.*; |
|
|
import org.apache.poi.ss.usermodel.*; |
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
@ -27,7 +25,6 @@ import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.File; |
|
|
import java.io.File; |
|
|
import java.io.FileOutputStream; |
|
|
import java.io.FileOutputStream; |
|
|
import java.io.OutputStream; |
|
|
import java.io.OutputStream; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.net.URLEncoder; |
|
|
import java.net.URLEncoder; |
|
|
import java.text.DecimalFormat; |
|
|
import java.text.DecimalFormat; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.text.SimpleDateFormat; |
|
@ -43,8 +40,6 @@ public class InventoryService extends ServiceImpl<InventoryMapper, Inventory> { |
|
|
|
|
|
|
|
|
@Value("${import.filePath}") |
|
|
@Value("${import.filePath}") |
|
|
private String filePath; |
|
|
private String filePath; |
|
|
@Autowired |
|
|
|
|
|
private HttpServletResponse response; |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean save(InventoryIndex inventoryIndex){ |
|
|
public ResultBean save(InventoryIndex inventoryIndex){ |
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
@ -52,17 +47,17 @@ public class InventoryService extends ServiceImpl<InventoryMapper, Inventory> { |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
BaseResponse<BaseResponseListObj<com.yxt.supervise.gf.shanhai.resp.Inventory>> api$system$inventory$index = ShRequester.getApi$system$inventory$index(inventoryIndex); |
|
|
BaseResponse<BaseResponseListObj<com.yxt.supervise.gf.shanhai.resp.Inventory>> api$system$inventory$index = ShRequester.getApi$system$inventory$index(inventoryIndex); |
|
|
List<com.yxt.supervise.gf.shanhai.resp.Inventory> list = api$system$inventory$index.getData().getList(); |
|
|
List<com.yxt.supervise.gf.shanhai.resp.Inventory> list = api$system$inventory$index.getData().getList(); |
|
|
try { |
|
|
|
|
|
exportExcel(response,list); |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
for (com.yxt.supervise.gf.shanhai.resp.Inventory inventory : list) { |
|
|
for (com.yxt.supervise.gf.shanhai.resp.Inventory inventory : list) { |
|
|
Inventory inventory1 = new Inventory(); |
|
|
Inventory inventory1 = new Inventory(); |
|
|
BeanUtil.copyProperties(inventory,inventory1); |
|
|
BeanUtil.copyProperties(inventory,inventory1); |
|
|
inventory1.setTime(sdf.format(date)); |
|
|
inventory1.setTime(sdf.format(date)); |
|
|
baseMapper.insert(inventory1); |
|
|
baseMapper.insert(inventory1); |
|
|
} |
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
exportExcel(list); |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
return rb.success().setMsg("添加成功"); |
|
|
return rb.success().setMsg("添加成功"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -71,13 +66,22 @@ public class InventoryService extends ServiceImpl<InventoryMapper, Inventory> { |
|
|
* @param list 导出数据 |
|
|
* @param list 导出数据 |
|
|
* @throws Exception |
|
|
* @throws Exception |
|
|
*/ |
|
|
*/ |
|
|
public void exportExcel(HttpServletResponse response, List<com.yxt.supervise.gf.shanhai.resp.Inventory> list) throws Exception { |
|
|
public void exportExcel(List<com.yxt.supervise.gf.shanhai.resp.Inventory> list) throws Exception { |
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
Date date = new Date(); |
|
|
Date date = new Date(); |
|
|
XSSFWorkbook wb = new XSSFWorkbook(); |
|
|
XSSFWorkbook wb = new XSSFWorkbook(); |
|
|
Map<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> listMap = list.stream().collect(Collectors.groupingBy(it -> it.getStorehouse_name())); |
|
|
Map<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> listMap = list.stream().collect(Collectors.groupingBy(it -> it.getStorehouse_name())); |
|
|
List<Map<String, Object>> listMap1 = new ArrayList<>();//存储汇总数据
|
|
|
List<Map<String, Object>> listMap1 = new ArrayList<>();//存储汇总数据
|
|
|
|
|
|
Map<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> map1 = new HashMap<>(); |
|
|
for (Map.Entry<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> stringListEntry : listMap.entrySet()) { |
|
|
for (Map.Entry<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> stringListEntry : listMap.entrySet()) { |
|
|
|
|
|
List<com.yxt.supervise.gf.shanhai.resp.Inventory> value = stringListEntry.getValue(); |
|
|
|
|
|
List<com.yxt.supervise.gf.shanhai.resp.Inventory> filterValue = null; |
|
|
|
|
|
filterValue = value.stream().filter(t -> t.getMateriel_group_text().equals("组件") || t.getMateriel_group_text().equals("逆变器")).collect(Collectors.toList()); |
|
|
|
|
|
if (filterValue.size() != 0){ |
|
|
|
|
|
map1.put(stringListEntry.getKey(),filterValue); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
for (Map.Entry<String, List<com.yxt.supervise.gf.shanhai.resp.Inventory>> stringListEntry : map1.entrySet()) { |
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
//标题行抽出字段
|
|
|
//标题行抽出字段
|
|
|
String[] head = {"序号","库存数量","仓库编码", "物料id", "物料编码", "物料组id", "物料品牌", "物料名称", "物料单价(成本价)", "最后更新时间", "物料组明文", "最后更新时间明文", "仓库名称","货值"}; |
|
|
String[] head = {"序号","库存数量","仓库编码", "物料id", "物料编码", "物料组id", "物料品牌", "物料名称", "物料单价(成本价)", "最后更新时间", "物料组明文", "最后更新时间明文", "仓库名称","货值"}; |
|
|