|
|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.gaotao.modules.finishedProduct.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.gaotao.common.constant.OutBoxConstant; |
|
|
|
import com.gaotao.common.constant.SysMsgConstant; |
|
|
|
import com.gaotao.common.exception.XJException; |
|
|
|
@ -37,6 +38,8 @@ public class PackingServiceImpl implements PackingService { |
|
|
|
private String bartenderPrintServerPath; |
|
|
|
@Value("${bartender.special.boxPrinterName}") |
|
|
|
private String boxPrinterName; |
|
|
|
@Value("${bartender.print.server.mixedBatchPrintLabel}") |
|
|
|
private String bartenderPrintBatch; |
|
|
|
@Autowired |
|
|
|
XuJieConfig xuJieConfig; |
|
|
|
|
|
|
|
@ -522,6 +525,138 @@ public class PackingServiceImpl implements PackingService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 新的方法解决打印的速度问题 新方法一次可以传多个打印的请求 数据不用再放入数据库 最新搬书本 |
|
|
|
* @author LR |
|
|
|
* @date 2026/3/17 14:44 |
|
|
|
* @version 1.0 |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
public void printPackingNew(ReportFileVo reportFileVo, HttpServletRequest request) { |
|
|
|
SysUserEntity user = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
log.info("开始装箱打印任务!"); |
|
|
|
// 打印数据 集合 2026-03-17 优化打印的功能 LR Start |
|
|
|
List<Map<String, Object>> printList = new ArrayList<>(); |
|
|
|
PickingInfo query = new PickingInfo(); |
|
|
|
query.setOrderStatus("N"); |
|
|
|
query.setOrderNo(Long.valueOf(reportFileVo.getOrderNo())); |
|
|
|
query.setPartNo(reportFileVo.getPartNo()); |
|
|
|
List<PickingInfo> pickingInfos = packingInfoService.getPickingList(query); |
|
|
|
PickingInfo pickingInfo = pickingInfos.get(0); |
|
|
|
double unitSalesQty = pickingInfo.getUnitSalesQty(); |
|
|
|
// 根据箱码获取 生产单号 |
|
|
|
String boxNo = reportFileVo.getBoxNo(); |
|
|
|
// 判断 该模板下是否还有对应的模板 |
|
|
|
// 本次打印使用客户表模板 |
|
|
|
List<ReportFileVo> reportFileVos = new ArrayList<>(); |
|
|
|
List<ReportFileVo> sumList = new ArrayList<>(); |
|
|
|
if ("Y".equals(reportFileVo.getIsCustomer())) { |
|
|
|
reportFileVos = reportFileDao.getReportFileListByParnetNo(reportFileVo.getReportId()); |
|
|
|
sumList = reportFileDao.getReportFileCustomerList(); |
|
|
|
} else { |
|
|
|
reportFileVos = reportFileDao.getReportFileListDefaultByParnetNo(reportFileVo.getReportId()); |
|
|
|
sumList = reportFileDao.getReportFileListDefaultList(); |
|
|
|
} |
|
|
|
List<ReportFileVo> sumReportFileVoList = new ArrayList<>(); |
|
|
|
sumReportFileVoList = getReportFileList(reportFileVos, sumList); |
|
|
|
sumReportFileVoList.add(reportFileVo); |
|
|
|
//添加子标签 2025-12-05 测试代码LR |
|
|
|
log.info("新增测试打印子标签内容:{}", reportFileVos.toString()); |
|
|
|
sumReportFileVoList.addAll(reportFileVos); |
|
|
|
log.info("新增测试打印全部标签内容:{}", sumReportFileVoList.toString()); |
|
|
|
// 打印API 地址 |
|
|
|
String apiAddress = ""; |
|
|
|
// 获取打印数据 |
|
|
|
List<Map<String, Object>> view = packingDao.getPrintBoxView(reportFileVo.getBoxNo()); |
|
|
|
// 获取打印数据列 |
|
|
|
Map<String, Object> paramMap = view.get(0); |
|
|
|
for (ReportFileVo fileVo : sumReportFileVoList) { |
|
|
|
// 装箱数量 |
|
|
|
Double pickingNumber = reportFileVo.getPickingNumber(); |
|
|
|
pickingNumber = pickingNumber/unitSalesQty;//2023-04-17 修改获取的数量 |
|
|
|
//查询打印的列信息 |
|
|
|
List<Reportcontentitem> reportcontentitemList = reportcontentitemService.getReportcontentitemList(fileVo.getReportId()); |
|
|
|
Map<String, String> itemMap = reportcontentitemList.stream().collect(Collectors.toMap(Reportcontentitem::getObjectgroup, Reportcontentitem::getDbfieldname)); |
|
|
|
|
|
|
|
// 获取卷标签打印模板 |
|
|
|
for (String key : itemMap.keySet()) { |
|
|
|
String dbName = itemMap.get(key); |
|
|
|
//数据库 $开头 数量 #开头 手工参数 排除 仅仅处理正常的参数 |
|
|
|
if (!(dbName.startsWith("$") || dbName.startsWith("#") || dbName.startsWith("流水号"))) { |
|
|
|
for (Map<String, Object> stringStringMap : view) { |
|
|
|
if (stringStringMap.containsKey(dbName)) { |
|
|
|
if (stringStringMap.get(dbName) != null) { |
|
|
|
itemMap.put(key, String.valueOf(stringStringMap.get(dbName))); |
|
|
|
} else { |
|
|
|
itemMap.put(key, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 手工参数 #子头 |
|
|
|
if (dbName.indexOf("#") == 0) { |
|
|
|
itemMap.put(key, StringUtils.isNotEmpty(String.valueOf(paramMap.get(key))) ? String.valueOf(paramMap.get(key)) : " "); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// $数量 参数 有尾箱数 最后一箱数量变化 |
|
|
|
if (itemMap.containsValue("$数量")) { |
|
|
|
DecimalFormat df = new DecimalFormat("#.###"); |
|
|
|
itemMap.put("数量", df.format(pickingNumber)); |
|
|
|
} |
|
|
|
// 3.判断是否包含流水号 包含测返回流水号 |
|
|
|
String seqNumber = reportfileSeqinfoService.getSeqNumber(fileVo.getReportId(), OutBoxConstant.SEQ_NUMBER, itemMap); |
|
|
|
//原佘莉写得方法 |
|
|
|
if (StringUtils.isNotEmpty(seqNumber)) { |
|
|
|
itemMap.put("流水号", seqNumber.toString()); |
|
|
|
} |
|
|
|
log.info("流水号处理完成"); |
|
|
|
|
|
|
|
// 获取 打印ip 和 打印机 |
|
|
|
ReportfilelistUserprinter userprinter = userprinterService.lambdaQuery() |
|
|
|
.eq(ReportfilelistUserprinter::getReportid, fileVo.getReportId()) |
|
|
|
.eq(ReportfilelistUserprinter::getUserid, user.getUsername()).one(); |
|
|
|
//检查 异常处理 |
|
|
|
if (userprinter == null) { |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200101)); |
|
|
|
} |
|
|
|
if (org.apache.commons.lang.StringUtils.isEmpty(userprinter.getIpaddress())) { |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200102)); |
|
|
|
} |
|
|
|
if (StringUtils.isEmpty(userprinter.getNewprintername())) { |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200103)); |
|
|
|
} |
|
|
|
apiAddress = "http://" + userprinter.getIpaddress() + ":" + bartenderPrintBatch; |
|
|
|
log.info("打印地址: "+ apiAddress); |
|
|
|
//打印参数 |
|
|
|
Map<String, Object> printOutMap = new HashMap<>(); |
|
|
|
String bartenderName = fileVo.getReportFile(); |
|
|
|
//判断是否含有.btw 含有去掉后缀 |
|
|
|
if (fileVo.getReportFile().contains(".btw")) { |
|
|
|
bartenderName = fileVo.getReportFile().substring(0, fileVo.getReportFile().toUpperCase().indexOf(".BTW")); |
|
|
|
} |
|
|
|
//组装打印的参数 |
|
|
|
printOutMap.put("printQty", 1); |
|
|
|
printOutMap.put("printerName", userprinter.getNewprintername()); |
|
|
|
printOutMap.put("btwName", bartenderName); |
|
|
|
printOutMap.put("printData", itemMap); |
|
|
|
//添加打印参数 |
|
|
|
printList.add(printOutMap); |
|
|
|
log.info("打印数据:{}", printOutMap.toString()); |
|
|
|
} |
|
|
|
// 调用接口传递参数 |
|
|
|
ResponseData r = HttpClientUtil.doPostByRaw(apiAddress, printList); |
|
|
|
log.info("打印数据:{}", JSON.toJSON(printList)); |
|
|
|
// 获取打印返回结果 |
|
|
|
if (!"200".equals(r.getCode())) { |
|
|
|
log.info("调用错误!" + r.getMsg()); |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200138) + r.getMsg()); |
|
|
|
} |
|
|
|
log.info("{},调用成功!", r.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @author: sxm |
|
|
|
|