Browse Source

消息提示多语言 print 2023年1月28日 sxm

master
[li_she] 3 years ago
parent
commit
b1bd2f371e
  1. 18
      src/main/java/com/gaotao/modules/print/controller/OutBoxPrintController.java
  2. 14
      src/main/java/com/gaotao/modules/print/controller/RollPrintController.java
  3. 12
      src/main/java/com/gaotao/modules/print/controller/SysUserPrinterController.java
  4. 42
      src/main/java/com/gaotao/modules/print/service/impl/OutBoxPrintServiceImpl.java
  5. 22
      src/main/java/com/gaotao/modules/print/service/impl/RollPrintServiceImpl.java

18
src/main/java/com/gaotao/modules/print/controller/OutBoxPrintController.java

@ -2,25 +2,25 @@ package com.gaotao.modules.print.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.gaotao.common.constant.SysMsgConstant;
import com.gaotao.common.exception.ResponseEnum;
import com.gaotao.common.utils.R;
import com.gaotao.modules.finishedProduct.dao.ReportfilelistUserprinterDao;
import com.gaotao.modules.print.entity.ReportParametersEntity;
import com.gaotao.modules.print.entity.vo.OutBoxParamVo;
import com.gaotao.modules.print.entity.vo.OutBoxPrintVo;
import com.gaotao.modules.print.entity.vo.ReportFileVo;
import com.gaotao.modules.print.service.OutBoxPrintService;
import com.gaotao.modules.print.service.ReportParametersService;
import com.gaotao.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@RequestMapping("outBoxPrint")
@RestController
public class OutBoxPrintController {
public class OutBoxPrintController extends AbstractController {
@Autowired
private OutBoxPrintService outBoxPrintService;
@ -41,7 +41,7 @@ public class OutBoxPrintController {
public R getBoxLabelSO(@PathVariable("orderNo") String orderNo) {
OutBoxPrintVo outBoxPrintVo = outBoxPrintService.getBoxLabelSO(orderNo);
if (outBoxPrintVo == null) {
return R.error(ResponseEnum.OUT_BOX_ORDER_NOT_FOUND);
return R.error(ResponseEnum.OUT_BOX_ORDER_NOT_FOUND.getCode(),getLanguageMsg(SysMsgConstant.OBJECT_ID_200127));
}
return R.ok().put("data", outBoxPrintVo);
}
@ -57,7 +57,7 @@ public class OutBoxPrintController {
public R getBoxLabelSOByRollNo(@PathVariable("rollNo") String rollNo) {
OutBoxPrintVo outBoxPrintVo = outBoxPrintService.getBoxLabelSOByRollNo(rollNo);
if (outBoxPrintVo == null) {
return R.error(ResponseEnum.OUT_BOX_ROLL_NOT_FOUND);
return R.error(ResponseEnum.OUT_BOX_ROLL_NOT_FOUND.getCode(),getLanguageMsg(SysMsgConstant.OBJECT_ID_200128));
}
return R.ok().put("data", outBoxPrintVo);
}
@ -75,7 +75,7 @@ public class OutBoxPrintController {
public R getReportFileByCustomer(@PathVariable("customerId") String customerId, @PathVariable("reportFamily") String reportFamily) {
List<Map<String, String>> report = outBoxPrintService.getReportFileByCustomer(customerId, reportFamily);
if (CollectionUtil.isEmpty(report)) {
return R.error(ResponseEnum.REPORT_FILE_NOT_FOUND);
return R.error(ResponseEnum.REPORT_FILE_NOT_FOUND.getCode(),getLanguageMsg(SysMsgConstant.OBJECT_ID_200129));
}
return R.ok().put("dataList", report);
}
@ -91,7 +91,7 @@ public class OutBoxPrintController {
public R getReportSubFileList(@RequestBody ReportFileVo reportFileVo) {
List<Map<String, String>> report = outBoxPrintService.getReportSubFileList(reportFileVo);
if (CollectionUtil.isEmpty(report)) {
return R.ok(ResponseEnum.SUB_REPORT_FILE_NOT_FOUND);
return R.error(ResponseEnum.SUB_REPORT_FILE_NOT_FOUND.getCode(),getLanguageMsg(SysMsgConstant.OBJECT_ID_200130));
}
return R.ok().put("data", report);
}
@ -119,10 +119,10 @@ public class OutBoxPrintController {
@PostMapping("ouBoxPrintLabel")
public R ouBoxPrint(@RequestBody OutBoxParamVo outBoxParamVo) {
if (CollectionUtil.isEmpty(outBoxParamVo.getReportFileList())){
return R.error(ResponseEnum.REPORT_FILE_NOT_FOUND);
return R.error(ResponseEnum.REPORT_FILE_NOT_FOUND.getCode(),getLanguageMsg(SysMsgConstant.OBJECT_ID_200131));
}
outBoxPrintService.ouBoxPrint(outBoxParamVo);
return R.ok(ResponseEnum.OUT_BOX_PRINT_SUCCESS);
return R.ok(getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
}
}

14
src/main/java/com/gaotao/modules/print/controller/RollPrintController.java

@ -1,9 +1,11 @@
package com.gaotao.modules.print.controller;
import com.gaotao.common.constant.SysMsgConstant;
import com.gaotao.common.exception.ResponseEnum;
import com.gaotao.common.utils.R;
import com.gaotao.modules.print.entity.vo.RollParamVo;
import com.gaotao.modules.print.service.RollPrintService;
import com.gaotao.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
@ -13,7 +15,7 @@ import java.util.Map;
@RequestMapping("rollPrint")
@RestController
public class RollPrintController {
public class RollPrintController extends AbstractController {
@Autowired
private RollPrintService rollPrintService;
@ -30,11 +32,11 @@ public class RollPrintController {
int count = rollPrintService.checkRollCustomer(rollNos);
switch (count){
case 0:
return R.error(ResponseEnum.CUSTOMER_NOT_FOUND);
return R.error(ResponseEnum.CUSTOMER_NOT_FOUND.getCode(),getLanguageMsg(SysMsgConstant.OBJECT_ID_200132));
case 1:
return R.ok();
default:
return R.error(ResponseEnum.CUSTOMER_OVER);
return R.error(ResponseEnum.CUSTOMER_OVER.getCode(),getLanguageMsg(SysMsgConstant.OBJECT_ID_200133));
}
}
@ -49,7 +51,7 @@ public class RollPrintController {
public R getRollCustomer(@PathVariable("rollNo") String rollNo){
Map<String,String> data = rollPrintService.getRollCustomer(rollNo);
if (CollectionUtils.isEmpty(data)){
return R.error(ResponseEnum.ROLL_PRINT_DATA_NOT_FOUND);
return R.error(ResponseEnum.ROLL_PRINT_DATA_NOT_FOUND.getCode(),getLanguageMsg(SysMsgConstant.OBJECT_ID_200134));
}
return R.ok().put("data",data);
}
@ -64,9 +66,9 @@ public class RollPrintController {
@PostMapping("printLabel")
public R rollPrint(@RequestBody RollParamVo rollParamVo){
if(CollectionUtils.isEmpty(rollParamVo.getRollNos())){
return R.ok(ResponseEnum.PRINT_ROLL_NOT_FOUND);
return R.error(ResponseEnum.PRINT_ROLL_NOT_FOUND.getCode(),getLanguageMsg(SysMsgConstant.OBJECT_ID_200135));
}
rollPrintService.rollPrint(rollParamVo);
return R.ok(ResponseEnum.ROLL_PRINT_SUCCESS);
return R.ok(getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
}
}

12
src/main/java/com/gaotao/modules/print/controller/SysUserPrinterController.java

@ -1,20 +1,24 @@
package com.gaotao.modules.print.controller;
import com.gaotao.common.exception.ResponseEnum;
import com.gaotao.common.constant.SysMsgConstant;
import com.gaotao.common.utils.R;
import com.gaotao.modules.print.entity.ReportFileListUserPrinters;
import com.gaotao.modules.print.entity.vo.ReportfilelistUserprinterVo;
import com.gaotao.modules.print.service.SysUserPrinterService;
import com.gaotao.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
// 用户打印机管理
@RequestMapping("sysUserPrinter")
@RestController
public class SysUserPrinterController {
public class SysUserPrinterController extends AbstractController {
@Autowired
private SysUserPrinterService userPrinterService;
@ -43,7 +47,7 @@ public class SysUserPrinterController {
@PostMapping("saveUserLabelPrint")
public R saveUserLabelPrint(@RequestBody ReportFileListUserPrinters reportfilelistUserprinter){
userPrinterService.saveUserLabelPrint(reportfilelistUserprinter);
return R.ok(ResponseEnum.SUCCESS);
return R.ok(getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
}
/**

42
src/main/java/com/gaotao/modules/print/service/impl/OutBoxPrintServiceImpl.java

@ -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);
}

22
src/main/java/com/gaotao/modules/print/service/impl/RollPrintServiceImpl.java

@ -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;
@ -17,6 +17,7 @@ import com.gaotao.modules.print.entity.vo.ReportFileVo;
import com.gaotao.modules.print.entity.vo.RollParamVo;
import com.gaotao.modules.print.service.LabelprinthistService;
import com.gaotao.modules.print.service.RollPrintService;
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;
@ -50,6 +51,9 @@ public class RollPrintServiceImpl implements RollPrintService {
@Autowired
private LabelprinthistService labelprinthistService;
@Autowired
private SysMsgService sysMsgService;
@Override
public int checkRollCustomer(List<String> rollNos) {
return rollPrintMapper.checkRollCustomer(rollNos);
@ -74,13 +78,13 @@ public class RollPrintServiceImpl implements RollPrintService {
.eq(ReportfilelistUserprinter::getReportid, reportFileVo.getReportId())
.eq(ReportfilelistUserprinter::getUserid, rollParamVo.getUserName()).one();
if (userprinter == null) {
throw new XJException(ResponseEnum.USER_PRINT_NOT_FUND);
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200101));
}
if (org.apache.commons.lang.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.获取模板信息
@ -166,13 +170,13 @@ public class RollPrintServiceImpl implements RollPrintService {
.eq(ReportfilelistUserprinter::getReportid, reportFileVo.getReportId())
.eq(ReportfilelistUserprinter::getUserid, rollParamVo.getUserName()).one();
if (userprinter == null) {
throw new XJException(ResponseEnum.USER_PRINT_NOT_FUND);
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200101));
}
if (org.apache.commons.lang.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));
}
apiAddress = "http://" + userprinter.getIpaddress() + ":" + bartenderPrintBatch;
log.info("打印地址: "+ apiAddress);
@ -195,7 +199,7 @@ public class RollPrintServiceImpl implements RollPrintService {
// 数据库 $开头 数量 #开头 手工参数 排除
if (dbName.indexOf("$") != 0 && dbName.indexOf("#") != 0 && key.indexOf("流水号") !=0 ) {
if (!printData.containsKey(dbName)) {
throw new XJException(key + "对应的属性: " + dbName + "未维护!");
throw new XJException(sysMsgService.getLanguageMsg(SysMsgConstant.OBJECT_ID_200139) +key+ " : " + dbName);
}
// 数据库数据
if (printData.get(dbName)!=null){
@ -242,7 +246,7 @@ public class RollPrintServiceImpl implements RollPrintService {
// 获取打印返回结果
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());
// 分两次批量插入

Loading…
Cancel
Save