|
|
|
@ -1,5 +1,10 @@
|
|
|
|
|
package com.hnac.hzims.spare.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
|
import com.alibaba.excel.converters.longconverter.LongStringConverter; |
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
|
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
@ -12,6 +17,7 @@ import com.hnac.hzims.spare.mapper.SpRecordMapper;
|
|
|
|
|
import com.hnac.hzims.spare.mapper.SpWarehouseInMapper; |
|
|
|
|
import com.hnac.hzims.spare.mapper.WtSpWarehouseMapper; |
|
|
|
|
import com.hnac.hzims.spare.service.*; |
|
|
|
|
import com.hnac.hzims.spare.vo.SpWarehouseInExportVO; |
|
|
|
|
import com.hnac.hzims.spare.vo.SpWarehouseInVO; |
|
|
|
|
import com.hnac.hzims.spare.vo.WtSpBasicVO; |
|
|
|
|
import com.hnac.hzims.spare.vo.WtSpManagementVO; |
|
|
|
@ -28,16 +34,20 @@ import org.springblade.system.feign.IDictBizClient;
|
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 服务实现类 |
|
|
|
@ -251,6 +261,106 @@ public class SpWarehouseInServiceImpl extends ServiceImpl<SpWarehouseInMapper, S
|
|
|
|
|
return page.setRecords(result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 入库单导出 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void exportSpWarehouseData(SpWarehouseInVO warehouseInVO, HttpServletResponse response) { |
|
|
|
|
ServletOutputStream outputStream = null; |
|
|
|
|
try { |
|
|
|
|
outputStream = response.getOutputStream(); |
|
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
|
if (null !=warehouseInVO.getCode()) { |
|
|
|
|
params.put("code",warehouseInVO.getCode()); |
|
|
|
|
} |
|
|
|
|
if (null !=warehouseInVO.getType()) { |
|
|
|
|
params.put("type",warehouseInVO.getType()); |
|
|
|
|
} |
|
|
|
|
if (null !=warehouseInVO.getStatus()) { |
|
|
|
|
params.put("status",warehouseInVO.getStatus()); |
|
|
|
|
} |
|
|
|
|
if (null !=warehouseInVO.getStartDate()) { |
|
|
|
|
params.put("startDate",warehouseInVO.getStartDate()); |
|
|
|
|
} |
|
|
|
|
if (null !=warehouseInVO.getEndDate()) { |
|
|
|
|
params.put("endDate",warehouseInVO.getEndDate()); |
|
|
|
|
} |
|
|
|
|
List<Long> longList = new ArrayList<>(); |
|
|
|
|
if (null!=warehouseInVO.getDeptId()) { |
|
|
|
|
R<List<Dept>> deptList = sysClient.getDeptChild(warehouseInVO.getDeptId()); |
|
|
|
|
for (int i = 0; i < deptList.getData().size(); i++) { |
|
|
|
|
longList.add(deptList.getData().get(i).getId()); |
|
|
|
|
} |
|
|
|
|
longList.add(warehouseInVO.getDeptId()); |
|
|
|
|
} |
|
|
|
|
if (longList.size()>0) { |
|
|
|
|
params.put("deptList",longList); |
|
|
|
|
} |
|
|
|
|
if (null!=warehouseInVO.getStorageRoom()) { |
|
|
|
|
params.put("warehouseId",warehouseInVO.getStorageRoom()); |
|
|
|
|
} |
|
|
|
|
params.put("tenantId", AuthUtil.getTenantId()); |
|
|
|
|
IPage<SpWarehouseInVO> page = new Page<>(); |
|
|
|
|
List<SpWarehouseInVO> warehouseInPage = baseMapper.selectPageList(page, params); |
|
|
|
|
// 导入列表
|
|
|
|
|
List<SpWarehouseInExportVO> warehouseInExportList = new ArrayList<>(); |
|
|
|
|
// 数据处理
|
|
|
|
|
warehouseInPage.forEach(warehouse -> { |
|
|
|
|
SpWarehouseInExportVO exportVO = new SpWarehouseInExportVO(); |
|
|
|
|
BeanUtils.copyProperties(warehouse, exportVO); |
|
|
|
|
int type = warehouse.getType().intValue(); |
|
|
|
|
// 入库类型
|
|
|
|
|
String typeName; |
|
|
|
|
if (type == WarehouseInType.BUY.getType()) { |
|
|
|
|
typeName = WarehouseInType.BUY.getName(); |
|
|
|
|
} else if (type == WarehouseInType.BACK.getType()) { |
|
|
|
|
typeName = WarehouseInType.BACK.getName(); |
|
|
|
|
} else if (type == WarehouseInType.ALLOT.getType()) { |
|
|
|
|
typeName = WarehouseInType.ALLOT.getName(); |
|
|
|
|
} else { |
|
|
|
|
typeName = WarehouseInType.OLD.getName(); |
|
|
|
|
} |
|
|
|
|
warehouse.setTypeName(typeName); |
|
|
|
|
// 时间格式
|
|
|
|
|
// warehouse.setStartTime(DateUtil.format(plan.getScheduledStartTime(), DateUtil.PATTERN_DATE));
|
|
|
|
|
// warehouse.setEndTime(DateUtil.format(plan.getScheduledEndTime(), DateUtil.PATTERN_DATE));
|
|
|
|
|
}); |
|
|
|
|
// 设置响应头
|
|
|
|
|
// URLEncoder.encode防止中文乱码
|
|
|
|
|
String fileName = URLEncoder.encode("入库单", "UTF-8"); |
|
|
|
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
|
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
|
// ExcelWriter初始化
|
|
|
|
|
ExcelWriter excelWriter = EasyExcel |
|
|
|
|
.write(response.getOutputStream()) |
|
|
|
|
.autoCloseStream(Boolean.TRUE) |
|
|
|
|
.registerConverter(new LongStringConverter()) |
|
|
|
|
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) |
|
|
|
|
.build(); |
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet(1, "入库单").head(SpWarehouseInExportVO.class) |
|
|
|
|
.build(); |
|
|
|
|
excelWriter.write(warehouseInExportList, writeSheet); |
|
|
|
|
excelWriter.finish(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 重置response
|
|
|
|
|
response.reset(); |
|
|
|
|
response.setContentType("application/json"); |
|
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
|
throw new ServiceException("入库单数据导出异常: " + e.getMessage()); |
|
|
|
|
} finally { |
|
|
|
|
if (outputStream != null) { |
|
|
|
|
try { |
|
|
|
|
outputStream.close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
log.error("入库单数据导出输出流关闭异常: " + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// public boolean completeTask(BladeFlow flow) {
|
|
|
|
|
// ComleteTask task = new ComleteTask();
|
|
|
|
|