|
|
|
@ -2,7 +2,7 @@ package com.gaotao.modules.print.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.gaotao.common.constant.OutBoxConstant; |
|
|
|
import com.gaotao.common.exception.ResponseEnum; |
|
|
|
import com.gaotao.common.constant.SysMsgConstant; |
|
|
|
import com.gaotao.common.exception.XJException; |
|
|
|
import com.gaotao.modules.finishedProduct.entity.Reportcontentitem; |
|
|
|
import com.gaotao.modules.finishedProduct.entity.ReportfilelistUserprinter; |
|
|
|
@ -18,6 +18,7 @@ import com.gaotao.modules.print.entity.vo.OutBoxPrintVo; |
|
|
|
import com.gaotao.modules.print.entity.vo.ReportFileVo; |
|
|
|
import com.gaotao.modules.print.service.LabelprinthistService; |
|
|
|
import com.gaotao.modules.print.service.OutBoxPrintService; |
|
|
|
import com.gaotao.modules.sys.service.SysMsgService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -51,6 +52,9 @@ public class OutBoxPrintServiceImpl implements OutBoxPrintService { |
|
|
|
@Autowired |
|
|
|
private LabelprinthistService labelprinthistService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysMsgService sysMsgService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public OutBoxPrintVo getBoxLabelSO(String orderNo) { |
|
|
|
return outBoxPrintMapper.getBoxLabelSO(orderNo); |
|
|
|
@ -77,20 +81,20 @@ public class OutBoxPrintServiceImpl implements OutBoxPrintService { |
|
|
|
// 获取打印数据 |
|
|
|
Double boxQty = outBoxParamVo.getBoxQty(); |
|
|
|
if (boxQty == null || boxQty == 0) { |
|
|
|
throw new XJException(ResponseEnum.OUT_BOX_QTY_NULL); |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200137)); |
|
|
|
} |
|
|
|
if (outBoxParamVo.getLastBoxQty() > 0.0) { |
|
|
|
boxQty += 1; |
|
|
|
} |
|
|
|
Map<String, String> boxPrintData = outBoxPrintMapper.getBoxLabelPrintData(outBoxParamVo); |
|
|
|
// 卷和箱子去不同的数据源 |
|
|
|
if (StringUtils.isNotEmpty(outBoxParamVo.getRollNo())){ |
|
|
|
if (StringUtils.isNotEmpty(outBoxParamVo.getRollNo())) { |
|
|
|
boxPrintData = outBoxPrintMapper.getBoxLabelPrintRollData(outBoxParamVo); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
boxPrintData = outBoxPrintMapper.getBoxLabelPrintData(outBoxParamVo); |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(boxPrintData)){ |
|
|
|
throw new XJException(ResponseEnum.PRINT_DATA_NOT_FOUND); |
|
|
|
if (CollectionUtils.isEmpty(boxPrintData)) { |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200136)); |
|
|
|
} |
|
|
|
List<Labelprinthist> histsList = new ArrayList<>(); |
|
|
|
Date date = new Date(); |
|
|
|
@ -102,13 +106,13 @@ public class OutBoxPrintServiceImpl implements OutBoxPrintService { |
|
|
|
.eq(ReportfilelistUserprinter::getReportid, reportFileVo.getReportId()) |
|
|
|
.eq(ReportfilelistUserprinter::getUserid, outBoxParamVo.getUserName()).one(); |
|
|
|
if (userprinter == null) { |
|
|
|
throw new XJException(ResponseEnum.USER_PRINT_NOT_FUND); |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200101)); |
|
|
|
} |
|
|
|
if (StringUtils.isEmpty(userprinter.getIpaddress())) { |
|
|
|
throw new XJException(ResponseEnum.USER_PRINT_IP_NOT_FUND); |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200102)); |
|
|
|
} |
|
|
|
if (StringUtils.isEmpty(userprinter.getNewprintername())) { |
|
|
|
throw new XJException(ResponseEnum.USER_PRINT_NAME_NOT_FUND); |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200103)); |
|
|
|
} |
|
|
|
String printPath = "http://" + userprinter.getIpaddress() + ":" + bartenderPrintServerPath; |
|
|
|
// 2.获取模板信息 |
|
|
|
@ -121,9 +125,9 @@ public class OutBoxPrintServiceImpl implements OutBoxPrintService { |
|
|
|
itemMap.put("流水号", seqNumber.toString()); |
|
|
|
} |
|
|
|
log.info("流水号处理完成"); |
|
|
|
// Map<String, String> paramMap = outBoxParamVo.getParam().stream().collect(Collectors.toMap(ReportParametersEntity::getParametername, ReportParametersEntity::getOptionvalue)); |
|
|
|
Map<String, String> paramMap = outBoxParamVo.getParam().stream().collect(HashMap::new,(m, v)->m.put(v.getParametername(),v.getOptionvalue()), HashMap::putAll); |
|
|
|
log.info("手工参数处理开始{}",paramMap.toString()); |
|
|
|
// Map<String, String> paramMap = outBoxParamVo.getParam().stream().collect(Collectors.toMap(ReportParametersEntity::getParametername, ReportParametersEntity::getOptionvalue)); |
|
|
|
Map<String, String> paramMap = outBoxParamVo.getParam().stream().collect(HashMap::new, (m, v) -> m.put(v.getParametername(), v.getOptionvalue()), HashMap::putAll); |
|
|
|
log.info("手工参数处理开始{}", paramMap.toString()); |
|
|
|
// 当返回的数据中没有映射的key时 提示属性未维护 |
|
|
|
for (String key : itemMap.keySet()) { |
|
|
|
String dbName = itemMap.get(key); |
|
|
|
@ -131,19 +135,19 @@ public class OutBoxPrintServiceImpl implements OutBoxPrintService { |
|
|
|
// 数据库 $开头 数量 #开头 手工参数 排除 |
|
|
|
if (dbName.indexOf("$") != 0 && dbName.indexOf("#") != 0 && key.indexOf("流水号") != 0) { |
|
|
|
if (!boxPrintData.containsKey(dbName)) { |
|
|
|
throw new XJException(key + "对应的属性: " + dbName + "未维护!"); |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200139) +key+ " : " + dbName); |
|
|
|
} |
|
|
|
// 数据库数据 |
|
|
|
if (boxPrintData.get(dbName) != null){ |
|
|
|
if (boxPrintData.get(dbName) != null) { |
|
|
|
itemMap.put(key, boxPrintData.get(dbName)); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
// 配置默认值 |
|
|
|
itemMap.put(key, ""); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 手工参数 #子头 |
|
|
|
if (dbName.indexOf("#") == 0) { |
|
|
|
itemMap.put(key, StringUtils.isNotEmpty(paramMap.get(key))?paramMap.get(key):" "); |
|
|
|
itemMap.put(key, StringUtils.isNotEmpty(paramMap.get(key)) ? paramMap.get(key) : " "); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -155,7 +159,7 @@ public class OutBoxPrintServiceImpl implements OutBoxPrintService { |
|
|
|
itemMap.put("数量", outBoxParamVo.getPerBoxQty().toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("手工参数处理结束{}",paramMap.toString()); |
|
|
|
log.info("手工参数处理结束{}", paramMap.toString()); |
|
|
|
// 打印接口参数集 |
|
|
|
Map<String, Object> printOutMap = new HashMap<>(); |
|
|
|
int printQty = StringUtils.isNotEmpty(paramMap.get(OutBoxConstant.COPIES)) ? Integer.valueOf(paramMap.get(OutBoxConstant.COPIES)) : 1; |
|
|
|
@ -169,7 +173,7 @@ public class OutBoxPrintServiceImpl implements OutBoxPrintService { |
|
|
|
// 获取打印返回结果 |
|
|
|
if (!"200".equals(r.getCode())) { |
|
|
|
log.info("调用错误!" + r.getMsg()); |
|
|
|
throw new XJException("错误信息:调用Bartender打印失败" + r.getMsg()); |
|
|
|
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200138) + r.getMsg()); |
|
|
|
} |
|
|
|
log.info("{},调用成功!", r.getMsg()); |
|
|
|
Labelprinthist labelprinthist = new Labelprinthist(); |
|
|
|
@ -177,7 +181,7 @@ public class OutBoxPrintServiceImpl implements OutBoxPrintService { |
|
|
|
labelprinthist.setCreatedate(date); |
|
|
|
labelprinthist.setUserid(outBoxParamVo.getUserName()); |
|
|
|
labelprinthist.setKeyinfo(StringUtils.isNotEmpty(outBoxParamVo.getOrderNo()) ? outBoxParamVo.getOrderNo() : outBoxParamVo.getRollNo()); |
|
|
|
labelprinthist.setPrintfrom(StringUtils.isNotEmpty(outBoxParamVo.getOrderNo())?OutBoxConstant.PRINT_TYPE_ORDER:OutBoxConstant.PRINT_TYPE_ROLL); |
|
|
|
labelprinthist.setPrintfrom(StringUtils.isNotEmpty(outBoxParamVo.getOrderNo()) ? OutBoxConstant.PRINT_TYPE_ORDER : OutBoxConstant.PRINT_TYPE_ROLL); |
|
|
|
labelprinthist.setPrintdetail(JSON.toJSONString(printOutMap)); |
|
|
|
histsList.add(labelprinthist); |
|
|
|
} |
|
|
|
|