opt:导出优化;add:增加人工点维护功能;添加区域看板

This commit is contained in:
zhangzq
2025-04-28 20:18:55 +08:00
parent cb69739175
commit 1006efa1b5
13 changed files with 355 additions and 71 deletions

View File

@@ -6,19 +6,29 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.b_lms.bst.ivt.cutpointivt.service.dto.BstIvtCutpointivtQuery;
import org.nl.b_lms.bst.ivt.cutpointivt.service.dto.BstIvtCutpointivtVo;
import org.nl.b_lms.bst.ivt.cutpointivt.service.dto.SubInfo;
import org.nl.b_lms.pdm.bi.slittingproductionplan.service.IPdmBiSlittingproductionplanService;
import org.nl.b_lms.pdm.bi.slittingproductionplan.service.dao.PdmBiSlittingproductionplan;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.modules.logging.annotation.Log;
import org.nl.b_lms.bst.ivt.cutpointivt.service.IBstIvtCutpointivtService;
import org.nl.b_lms.bst.ivt.cutpointivt.service.dao.BstIvtCutpointivt;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.Set;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
/**
* @author lyd
* @date 2024-02-26
@@ -30,6 +40,8 @@ public class BstIvtCutpointivtController {
@Autowired
private IBstIvtCutpointivtService bstIvtCutpointivtService;
@Autowired
private IPdmBiSlittingproductionplanService iPdmBiSlittingproductionplanService;
@GetMapping
@Log("查询分切区缓存点位库存")
@@ -74,6 +86,50 @@ public class BstIvtCutpointivtController {
if (StringUtils.isNotEmpty(暂存架区域)){
queryWrapper.eq("point_type", 暂存架区域);
}
return new ResponseEntity<>(bstIvtCutpointivtService.list(queryWrapper),HttpStatus.OK);
List<BstIvtCutpointivt> list = bstIvtCutpointivtService.list(queryWrapper);
ArrayList<String> qzzs = new ArrayList<>();
for (BstIvtCutpointivt cutpointivt : list) {
String qzzNo1 = cutpointivt.getQzz_no1();
String qzzNo2 = cutpointivt.getQzz_no2();
if (StringUtils.isNotEmpty(qzzNo1)){qzzs.add(qzzNo1);};
if (StringUtils.isNotEmpty(qzzNo2)){qzzs.add(qzzNo2);};
}
List<PdmBiSlittingproductionplan> slit = iPdmBiSlittingproductionplanService.list(new QueryWrapper<PdmBiSlittingproductionplan>()
.select("qzzno","container_name", "split_breadth", "split_height", "split_weight")
.eq("is_delete", "0")
.ne("description","虚拟卷")
.in("qzzno", qzzs));
Map<String, List<PdmBiSlittingproductionplan>> slitMap = slit.stream().collect(Collectors.groupingBy(PdmBiSlittingproductionplan::getQzzno));
List<Object> result = new ArrayList<>();
for (BstIvtCutpointivt cutpointivt : list) {
BstIvtCutpointivtVo vo = new BstIvtCutpointivtVo();
vo.setQzz_no1(cutpointivt.getQzz_no1());
vo.setQzz_no2(cutpointivt.getQzz_no2());
vo.setPoint_type(cutpointivt.getPoint_type());
vo.setPoint_code(cutpointivt.getPoint_code());
vo.setPoint_status(cutpointivt.getPoint_status());
vo.setProduct_area(cutpointivt.getProduct_area());
vo.setUpdate_time(cutpointivt.getUpdate_time());
Map<String, List<String>> subInfo = new HashMap<>();
if (StringUtils.isNotEmpty(cutpointivt.getQzz_no1())){
List<PdmBiSlittingproductionplan> qzz1 = slitMap.get(cutpointivt.getQzz_no1());
if (!CollectionUtils.isEmpty(qzz1)){
List<String> collect = qzz1.stream()
.map(sub -> sub.getContainer_name()+"幅宽"+sub.getSplit_breadth().intValue()+"长度"+sub.getSplit_height().intValue()).collect(Collectors.toList());
subInfo.put(cutpointivt.getQzz_no1(),collect);
}
}
if (StringUtils.isNotEmpty(cutpointivt.getQzz_no2())){
List<PdmBiSlittingproductionplan> qzz2 = slitMap.get(cutpointivt.getQzz_no2());
if (!CollectionUtils.isEmpty(qzz2)){
List<String> collect = qzz2.stream()
.map(sub -> sub.getContainer_name()+"幅宽"+sub.getSplit_breadth().intValue()+"长度"+sub.getSplit_height().intValue()).collect(Collectors.toList());
subInfo.put(cutpointivt.getQzz_no2(),collect);
}
}
vo.setSubInfo(subInfo);
result.add(vo);
}
return new ResponseEntity<>(result,HttpStatus.OK);
}
}

View File

@@ -0,0 +1,20 @@
package org.nl.b_lms.bst.ivt.cutpointivt.service.dto;
import lombok.Data;
import org.nl.b_lms.bst.ivt.cutpointivt.service.dao.BstIvtCutpointivt;
import java.util.List;
import java.util.Map;
/**
* @description /
* @author lyd
* @date 2024-02-26
**/
@Data
public class BstIvtCutpointivtVo extends BstIvtCutpointivt {
/**
* 气胀轴子卷信息
*/
private Map<String,List<String>> subInfo;
}

View File

@@ -0,0 +1,30 @@
package org.nl.b_lms.bst.ivt.cutpointivt.service.dto;
import lombok.Builder;
import lombok.Data;
/**
* @description /
* @author lyd
* @date 2024-02-26
**/
@Data
@Builder
public class SubInfo {
/**
* 气胀轴子卷号
*/
private String container_name;
/**
* 子卷幅宽
*/
private Integer split_breadth;
/**
* 子卷长度
*/
private Integer split_height;
/**
* 子卷重量
*/
private Integer split_weight;
}

View File

@@ -34,4 +34,6 @@ public interface PdmBiSubpackagerelationMapper extends BaseMapper<PdmBiSubpackag
List<JSONObject> getStructInfoBySZLS();
List<JSONObject> recordQuery(List<String> pcns);
}

View File

@@ -113,6 +113,13 @@
<select id="getStructInfoBySZLS" resultType="com.alibaba.fastjson.JSONObject">
select struct_code,storagevehicle_code from st_ivt_structattr where sect_code IN ('ZC01','KTP01','ZZ01','PD01')
</select>
<select id="recordQuery" resultType="com.alibaba.fastjson.JSONObject">
select sale_order_name,container_name,insert_time from pdm_bi_subpackagerelationrecord where container_name in
<foreach collection="pcns" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND io_type = '0'
</select>
</mapper>

View File

@@ -132,6 +132,8 @@ public interface IpdmBiSubpackagerelationService extends IService<PdmBiSubpackag
*/
List<JSONObject> getStructInfoBySZLS();
List<JSONObject> recordQuery(List<String> pcsn);
}

View File

@@ -795,6 +795,10 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
return this.baseMapper.getStructInfoBySZLS();
}
@Override
public List<JSONObject> recordQuery(List<String> pcsn) {
return this.baseMapper.recordQuery(pcsn);
}
@Override
public void boxReturn(JSONObject whereJson) {

View File

@@ -126,7 +126,9 @@ public class BstIvtPackageinfoivtServiceImpl extends ServiceImpl<BstIvtPackagein
Set<String> containers = records.stream().map(BstIvtPackageinfoivt::getContainer_name).filter(a->StringUtils.isNotEmpty(a)).collect(Collectors.toSet());
Map<String,PdmBiSlittingproductionplan> listMap = new HashMap();
if (!CollectionUtils.isEmpty(containers)){
List<PdmBiSlittingproductionplan> containerInfo = iPdmBiSlittingproductionplanService.list(new QueryWrapper<PdmBiSlittingproductionplan>().in("container_name", containers).select("container_name", "weight", "paper_weight"));
List<PdmBiSlittingproductionplan> containerInfo = iPdmBiSlittingproductionplanService.list(new QueryWrapper<PdmBiSlittingproductionplan>()
.in("container_name", containers)
.select("container_name", "weight", "paper_weight","split_breadth","split_height"));
listMap = containerInfo.stream().collect(HashMap::new,(m, o) -> m.put(o.getContainer_name(),o), HashMap::putAll);
}
List<BstIvtPackageinfoivtVO> voRecords = new ArrayList<>();
@@ -1003,7 +1005,7 @@ public class BstIvtPackageinfoivtServiceImpl extends ServiceImpl<BstIvtPackagein
if (StringUtils.isBlank(whereJson.getString("ivt_status"))) {
throw new BadRequestException("子卷检验结果为空");
}
//"空","0","空载具","1","有子卷","2","合格品","3","管制品","4"
//"空","0","空载具","1","有子卷","2","合格品","3","管制品","4",人工卷,"5"
List<BstIvtPackageinfoivt> dtoList;
UpdateWrapper<BstIvtPackageinfoivt> updateWrapper = new UpdateWrapper<>();
//LMS获取MES称重后子卷信息

View File

@@ -68,29 +68,18 @@ public class TwoOutBoxTask extends AbstractAcsTask {
/*
* 下发给ACS时需要特殊处理
*/
// 任务表
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
// 装箱点位库存表
WQLObject packTab = WQLObject.getWQLObject("bst_ivt_packageinfoivt");
JSONArray arr = taskTab.query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0' order by create_time").getResultJSONArray(0);
// 判断当前有多少个正在执行中的任务
int num = taskTab.query("handle_class = '" + THIS_CLASS + "' and task_status IN ('05','06') and is_delete ='0'")
int num = WQLObject.getWQLObject("SCH_BASE_Task").query("handle_class = '" + THIS_CLASS + "' and task_status IN ('05','06') and is_delete ='0'")
.getResultJSONArray(0).size();
// 查询装箱对接位是否有木箱
JSONObject jsonPack = packTab.query("point_code = '" + PackageInfoIvtEnum.PACK_POINT.code("装箱对接位01") + "' AND is_used = '1'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonPack.getString("container_name"))) {
num += 1;
}
ArrayList<AcsTaskDto> resultList = new ArrayList<>();
// 如果缓存了4个箱子则不下发任务
if (num >= 3) {
if (num >= 2) {
return resultList;
}
JSONArray arr = WQLObject.getWQLObject("SCH_BASE_Task").query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0' order by create_time").getResultJSONArray(0);
for (int i = 0; i < arr.size(); i++) {
if (num >= 3) {
if (num >= 2) {
break;
}
JSONObject json = arr.getJSONObject(i);
@@ -142,7 +131,6 @@ public class TwoOutBoxTask extends AbstractAcsTask {
.remark(json.getString("remark"))
.build();
resultList.add(dto);
num += 1;
}
return resultList;
@@ -151,33 +139,32 @@ public class TwoOutBoxTask extends AbstractAcsTask {
@Override
@Transactional(rollbackFor = Exception.class)
public void updateTaskStatus(JSONObject taskObj, String status) {
// 仓位表
WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr");
// 仓位表
WQLObject packageinfoivt = WQLObject.getWQLObject("bst_ivt_packageinfoivt");
// 任务表
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
JSONObject jsonTask = taskTab.query("task_id = '" + taskObj.getString("task_id") + "'").uniqueResult(0);
// 更新任务的参数
JSONObject map = new JSONObject();
/*
* 1-执行中, 2-完成 ,0-acs取消
*/
// 执行中
if (status.equals(TaskStatusEnum.EXECUTING.getCode())) {
map.put("task_status", TaskStatusEnum.EXECUTING.getCode());
}else if (status.equals(IOSEnum.IS_NOTANDYES.code(""))) {
map.put("is_delete", IOSEnum.IS_NOTANDYES.code(""));
}else {
map.put("task_status", TaskStatusEnum.FINISHED.getCode());
}
map.put("update_optid", SecurityUtils.getCurrentUserId());
map.put("update_optname", SecurityUtils.getCurrentNickName());
map.put("update_time", DateUtil.now());
WQLObject.getWQLObject("SCH_BASE_Task").update(map, "task_id = '" + taskObj.getString("task_id") + "'");
// 完成
if (status.equals(TaskStatusEnum.FINISHED.getCode())) {
map.put("task_status", TaskStatusEnum.FINISHED.getCode());
// 更新仓位
JSONObject jsonAttr = attrTab.query("struct_code = '" + jsonTask.getString("point_code1") + "'").uniqueResult(0);
jsonAttr.put("lock_type", IOSEnum.LOCK_TYPE.code("未锁定"));
@@ -188,11 +175,11 @@ public class TwoOutBoxTask extends AbstractAcsTask {
packageInfo.put("ivt_status", PackageInfoIvtEnum.IVT_STATUS.code("空载具"));
packageInfo.put("container_name",jsonTask.getString("vehicle_code"));
packageinfoivt.update(packageInfo);
//更新木箱信息
// packageinfoivtService.update(new LambdaUpdateWrapper<BstIvtPackageinfoivt>()
// .eq(BstIvtPackageinfoivt::getPoint_code, jsonTask.getString("point_code2"))
// .set(BstIvtPackageinfoivt::getIvt_status, PackageInfoIvtEnum.IVT_STATUS.code("空载具"))
// .set(BstIvtPackageinfoivt::getContainer_name, jsonTask.getString("vehicle_code")));
RedissonUtils.lock(c->{
if (status.equals(TaskStatusEnum.FINISHED.getCode())) {
immediateNotifyAcs(null);
}
},"zjInBound",20,this);
}
// 取消
if (status.equals(IOSEnum.IS_NOTANDYES.code(""))) {
@@ -206,15 +193,6 @@ public class TwoOutBoxTask extends AbstractAcsTask {
jsonAttr.put("lock_type", IOSEnum.LOCK_TYPE.code("未锁定"));
attrTab.update(jsonAttr);
}
map.put("update_optid", SecurityUtils.getCurrentUserId());
map.put("update_optname", SecurityUtils.getCurrentNickName());
map.put("update_time", DateUtil.now());
WQLObject.getWQLObject("SCH_BASE_Task").update(map, "task_id = '" + taskObj.getString("task_id") + "'");
RedissonUtils.lock(c->{
if (status.equals(TaskStatusEnum.FINISHED.getCode())) {
immediateNotifyAcs(null);
}
},"zjInBound",10,this);
}

View File

@@ -0,0 +1,23 @@
package org.nl.modules.common.base;
import lombok.Data;
import org.apache.commons.lang.builder.ToStringBuilder;
import java.io.Serializable;
import java.util.Map;
@Data
public class BlockItemDTO implements Serializable {
private static final long serialVersionUID = 4337563581927229706L;
/**
* 主键(分块明细项Id)
*/
private Long id;
/**
* Excel一行数据(key为列名[columns_name可以和Excel列显示名不一致],value为单元格内容)
*/
private Map<String,String> columnMap;
}

View File

@@ -19,11 +19,18 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.poi.excel.BigExcelWriter;
import cn.hutool.poi.excel.ExcelUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.nl.modules.common.base.BlockItemDTO;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.enums.CellTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
@@ -33,6 +40,7 @@ import java.io.*;
import java.security.MessageDigest;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -43,9 +51,10 @@ import java.util.Map;
* @author Zheng Jie
* @date 2018-12-27
*/
@Slf4j
public class FileUtil extends cn.hutool.core.io.FileUtil {
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
private Integer batchWriteExcelRowAmount = 500;
/**
* 系统临时目录
@@ -234,6 +243,88 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
}
/**
* 流导出
* @param list
* @param response
* @throws IOException
*/
public void downloadExcelIO(List<Map<String,String>> list, String[] columnExcelNameArr, HttpServletResponse response) {
List<Map<String,String>> lastRestDataList = list;
List<List<Map<String,String>>> dataPiece = Lists.partition(list, 5000);
int blockNum = 0;
int blockNumMax = dataPiece.size();
List<String> allFileLocations = new ArrayList<>();
ServletOutputStream out = null;
try {
boolean allFinish = false;
while (!allFinish) {
int thisFileRowNumber = 1;
SXSSFWorkbook wb = null;
try {
// if (blockNum<blockNumMax){
// lastRestDataList = dataPiece.get(blockNum);
// blockNum++;
// }
// if (blockNum==blockNumMax){
// allFinish = true;
// }
wb = new SXSSFWorkbook(this.batchWriteExcelRowAmount);// 流式写入EXCEL只保留少数行(比如50行)数据在内存,防止内存溢出
Sheet sh = wb.createSheet();
Row titleRow = sh.createRow(0);
for (int cellNum = 0; cellNum < columnExcelNameArr.length; cellNum++) {
Cell cell = titleRow.createCell(cellNum);
cell.setCellValue(columnExcelNameArr[cellNum]);
}
if (!CollectionUtils.isEmpty(lastRestDataList)) {
for (int i = 0; i < lastRestDataList.size(); i++) {
Row dataRow = sh.createRow(thisFileRowNumber);
Map<String, String> columnMap = lastRestDataList.get(i);
for (int cellNum = 0; cellNum < columnExcelNameArr.length; cellNum++) {
Cell cell = dataRow.createCell(cellNum);
String valueStr = columnMap.get(columnExcelNameArr[cellNum]);
cell.setCellValue(valueStr);
}
thisFileRowNumber++;
}
}
String localFilePath = SYS_TEM_DIR + IdUtil.fastSimpleUUID()+ blockNum + ".xlsx";
allFileLocations.add(localFilePath);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="+localFilePath);
out = response.getOutputStream();
wb.write(out);
// 必须清理流式写入Excel生成的临时文件
wb.dispose();
allFinish = true;
}catch (Exception ex){
log.warn(ex.getMessage());
throw new BadRequestException(ex.getMessage());
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (IOException e) {log.warn(e.getMessage());}
}
if (wb != null) {
try {
wb.dispose();
} catch (Exception e) {log.warn(e.getMessage());}
}
}
}
}finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (IOException e) {log.warn(e.getMessage());}
}
}
}
public static String getFileType(String type) {
String documents = "txt doc pdf ppt pps xlsx xls docx";
String music = "mp3 wav wma mpa ram ra aac aif m4a";
@@ -351,4 +442,19 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
return getMd5(getByte(file));
}
private CellStyle createCellStyle(SXSSFWorkbook wb){
try{
CellStyle cellStyle = wb.createCellStyle();
DataFormat dataFormat = wb.createDataFormat();
String[] formats = CellTypeEnum.get_formats();
short format = dataFormat.getFormat(formats[3]);
cellStyle.setDataFormat(format);
return cellStyle;
}catch (Exception ee){
return null;
}
}
}

View File

@@ -0,0 +1,45 @@
package org.nl.modules.common.utils.enums;
/**
* 单元格格式类型新增
*/
public enum CellTypeEnum {
/**
* 数字类型
*/
NUMERIC("numeric"),
/**
* 字符串类型
*/
STRING("string"),
/**
* 自定义类型:数字三位分割
*/
NUMERIC_DIV("division");
private final static String[] _formats = {
"General",//0
"0",//1
"0.00",//2
"#,##0",//3
"#,##0.00"//4
};
private String code;
CellTypeEnum(String code){
this.code = code;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public static String[] get_formats() {
return _formats;
}
}

View File

@@ -8,8 +8,10 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.pdm.subpackagerelation.service.IpdmBiSubpackagerelationService;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.FileUtil;
@@ -18,6 +20,7 @@ import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.WqlUtil;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.wms.stat.service.OutBillQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -25,6 +28,10 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -37,7 +44,8 @@ import java.util.stream.Collectors;
@Slf4j
public class OutBillQueryServiceImpl implements OutBillQueryService {
@Autowired
private IpdmBiSubpackagerelationService ipdmBiSubpackagerelationService;
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page, String[] bill_types) {
String stor_id = MapUtil.getStr(whereJson, "stor_id");
@@ -271,14 +279,12 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
@Override
public void download2(Map map, HttpServletResponse response, String[] bill_types) throws IOException {
String stor_id = MapUtil.getStr(map, "stor_id");
String bill_type = MapUtil.getStr(map, "bill_type");
String with = MapUtil.getStr(map, "with"); // 厚度*幅宽
String begin_time = MapUtil.getStr(map, "begin_time");
String end_time = MapUtil.getStr(map, "end_time");
String pcsn = MapUtil.getStr(map, "pcsn");
String customer_name = MapUtil.getStr(map, "customer_name");
map.put("flag", "22");
map.put("stor_id", stor_id);
if (ObjectUtil.isNotEmpty(bill_types)) {
@@ -293,11 +299,9 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
if (StrUtil.isNotEmpty(pcsn)){
// 判断是否有空格
boolean matches = pcsn.matches(".*\\s.*");
if (matches) {
String[] s = pcsn.split(" ");
String pcsn_in = String.join("','", Arrays.asList(s));
map.put("pcsn_in", "('"+pcsn_in+"')");
map.put("pcsn", "");
} else {
@@ -307,44 +311,43 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
if (ObjectUtil.isNotEmpty(customer_name)) {
map.put("customer_name", "%" + customer_name + "%");
}
// 处理时间
if (ObjectUtil.isNotEmpty(begin_time) && ObjectUtil.isNotEmpty(end_time)) {
String begin_time_today = begin_time.substring(0, 10);
String end_time_today = end_time.substring(0, 10);
// 开始时间
String today_begin_time = begin_time_today + " 08:00:00";
// 结束时间19:59:59
DateTime parse = DateUtil.parse(end_time_today);
String substring = DateUtil.offsetDay(parse, 1).toString().substring(0, 10);
String today_end_time = substring + " 07:59:59";
map.put("begin_time", today_begin_time);
map.put("end_time", today_end_time);
}
JSONArray resultJSONArray = WQL.getWO("ST_IVT_OUTBILLQUERY").addParamMap(map).process().getResultJSONArray(0);
List<JSONObject> content = resultJSONArray.toJavaList(JSONObject.class);
String pcsn_in = content.stream()
List<String> pcsns = content.stream()
.map(row -> row.getString("pcsn"))
.collect(Collectors.joining("','"));
.collect(Collectors.toList());
List<JSONObject> subList = WQLObject.getWQLObject("pdm_bi_subpackagerelationrecord")
.query("container_name IN ('" + pcsn_in + "') AND io_type = '0' ORDER BY insert_time")
.getResultJSONArray(0).toJavaList(JSONObject.class);
List<Map<String, Object>> list = new ArrayList<>();
ConcurrentLinkedDeque<List<JSONObject>> deque = new ConcurrentLinkedDeque<>();
Lists.partition(pcsns,500).stream()
.map((Function<List<String>, CompletableFuture>) o->CompletableFuture.runAsync(() -> {
List<JSONObject> subList = ipdmBiSubpackagerelationService.recordQuery(o);
deque.add(subList);
})).parallel().forEach(CompletableFuture::join);
System.out.println("导出数据:"+deque.size());
List<JSONObject> datas = new ArrayList<>();
for (List<JSONObject> jsonObjects : deque) {
datas.addAll(jsonObjects);
}
List<Map<String, String>> list = new ArrayList<>();
for (int i = 0; i < resultJSONArray.size(); i++) {
JSONObject json = resultJSONArray.getJSONObject(i);
Map<String, Object> mp = new LinkedHashMap<>();
Map<String, String> mp = new LinkedHashMap<>();
// 查询第一次入库的源销售订单
JSONObject jsonSub = subList.stream()
JSONObject jsonSub = datas.stream()
.filter(row -> row.getString("container_name").equals(json.getString("pcsn")))
.min(Comparator.comparing(row -> row.getString("insert_time")))
.orElse(null);
@@ -445,7 +448,6 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
}
}
}
mp.put("业务员", json.getString("sales_owner"));
mp.put("出库日期", json.getString("input_time"));
mp.put("产品规格", String.format("%.0f", json.getDoubleValue("width")));
@@ -455,7 +457,14 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
mp.put("备注", json.getString("remark"));
list.add(mp);
}
FileUtil.downloadExcel(list, response);
Set<String> set = list.get(0).keySet();
int colIndex = 0;
String[] col = new String[set.size()];
for (String s : set) {
col[colIndex]=s;
colIndex++;
}
new FileUtil().downloadExcelIO(list,col,response);
// FileUtil.downloadExcel(list, response);
}
}