|
|
@ -25,10 +25,22 @@ |
|
|
|
*********************************************************/ |
|
|
|
package com.yxt.supervise.portal.biz.gdinventory; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
import cn.hutool.core.io.resource.ResourceUtil; |
|
|
|
import cn.hutool.poi.excel.ExcelUtil; |
|
|
|
import cn.hutool.poi.excel.ExcelWriter; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.net.URL; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: yxt_supervise <br/> |
|
|
|
* File: GdInventoryOkService.java <br/> |
|
|
@ -44,17 +56,95 @@ import org.springframework.stereotype.Service; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class GdInventoryOkService extends ServiceImpl<GdInventoryOkMapper, GdInventoryOk> { |
|
|
|
@Value("${image.upload.path:static/upload/}") |
|
|
|
private String uploadPath; |
|
|
|
|
|
|
|
public void clearData() { |
|
|
|
baseMapper.clearData(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 库存汇总 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean kchz() { |
|
|
|
|
|
|
|
int type1 = baseMapper.countWarehouseType1Not112(); |
|
|
|
int type2 = baseMapper.countWarehouseType2(); |
|
|
|
int prod112 = baseMapper.countProd112(); |
|
|
|
int prod1Not112 = baseMapper.countProd1Not112(); |
|
|
|
int prod2 = baseMapper.countProd2(); |
|
|
|
int prod1Not112 = baseMapper.countProd1Not112(); |
|
|
|
int prod2 = baseMapper.countProd2(); |
|
|
|
double val112 = baseMapper.countVal112(); |
|
|
|
double val1Not112 = baseMapper.countVal1Not112(); |
|
|
|
double val2 = baseMapper.countVal2(); |
|
|
|
|
|
|
|
Date curDate = new Date(); |
|
|
|
String timestr = DateUtil.format(curDate, "yyyyMMddHHmmssSSS"); |
|
|
|
String dfmt = DateUtil.format(curDate, "yyyy-MM-dd"); |
|
|
|
String datefmt1 = DateUtil.format(curDate, "yyyy-MM-dd HH:mm"); |
|
|
|
String datefmt2 = DateUtil.format(curDate, "yyyy/MM/dd HH:mm"); |
|
|
|
|
|
|
|
URL resource = ResourceUtil.getResource("xlsx-tmpl/库存汇总表.xlsx"); |
|
|
|
String toFileName = uploadPath + "kchzb/库存汇总表" + dfmt + ".xlsx"; |
|
|
|
File file = FileUtil.file(toFileName); |
|
|
|
FileUtil.copy(FileUtil.file(resource), file, true); |
|
|
|
ExcelWriter writer = ExcelUtil.getWriter(file); |
|
|
|
writer.setSheet(0); |
|
|
|
writer.writeCellValue(0, 1, "编号:" + timestr); |
|
|
|
writer.writeCellValue(3, 1, datefmt1); |
|
|
|
writer.writeCellValue(1, 3, 1); |
|
|
|
writer.writeCellValue(1, 4, type1); |
|
|
|
writer.writeCellValue(1, 5, type2); |
|
|
|
writer.writeCellValue(2, 3, prod112); |
|
|
|
writer.writeCellValue(2, 4, prod1Not112); |
|
|
|
writer.writeCellValue(2, 5, prod2); |
|
|
|
writer.writeCellValue(3, 3, val112); |
|
|
|
writer.writeCellValue(3, 4, val1Not112); |
|
|
|
writer.writeCellValue(3, 5, val2); |
|
|
|
// writer.flush();
|
|
|
|
// writer.close();
|
|
|
|
|
|
|
|
List<Map<String, Object>> list = baseMapper.listOfWarehouse(); |
|
|
|
// writer = ExcelUtil.getWriter(file);
|
|
|
|
writer.setSheet(1); |
|
|
|
writer.writeCellValue(0, 1, "编号:" + timestr); |
|
|
|
writer.writeCellValue(3, 1, datefmt1); |
|
|
|
int size = list.size(); |
|
|
|
int countRow = size + 3; |
|
|
|
for (int y = 3; y < countRow; y++) { |
|
|
|
Map<String, Object> map = list.get(y - 3); |
|
|
|
writer.writeCellValue(0, y, map.get("warehouseName")); |
|
|
|
writer.writeCellValue(1, y, map.get("warehouseType")); |
|
|
|
writer.writeCellValue(2, y, map.get("coun")); |
|
|
|
writer.writeCellValue(3, y, map.get("su")); |
|
|
|
} |
|
|
|
writer.writeCellValue(0, countRow, "合计"); |
|
|
|
// writer.flush();
|
|
|
|
// writer.close();
|
|
|
|
|
|
|
|
List<Map<String, Object>> listp = baseMapper.listOfProd(); |
|
|
|
// writer = ExcelUtil.getWriter(file);
|
|
|
|
writer.setSheet(2); |
|
|
|
writer.writeCellValue(0, 1, "编号:" + timestr); |
|
|
|
writer.writeCellValue(6, 1, datefmt2); |
|
|
|
int sizep = listp.size(); |
|
|
|
int countRowp = sizep + 3; |
|
|
|
for (int y = 3; y < countRowp; y++) { |
|
|
|
Map<String, Object> map = listp.get(y - 3); |
|
|
|
writer.writeCellValue(0, y, map.get("warehouseCode")); |
|
|
|
writer.writeCellValue(1, y, map.get("warehouseName")); |
|
|
|
writer.writeCellValue(2, y, map.get("warehouseType")); |
|
|
|
writer.writeCellValue(3, y, map.get("prodCode")); |
|
|
|
writer.writeCellValue(4, y, map.get("prodBarCode")); |
|
|
|
writer.writeCellValue(5, y, map.get("prodName")); |
|
|
|
writer.writeCellValue(6, y, map.get("prodNum")); |
|
|
|
writer.writeCellValue(7, y, map.get("prodValue")); |
|
|
|
} |
|
|
|
writer.flush(); |
|
|
|
writer.close(); |
|
|
|
|
|
|
|
|
|
|
|
return ResultBean.fireSuccess(); |
|
|
|
} |
|
|
|
} |
|
|
|