feat(打印机绑定):新增打印机绑定
This commit is contained in:
parent
1ddc07fed3
commit
f24f595477
@ -0,0 +1,11 @@
|
||||
package com.foreverwin.nlv.print.constant;
|
||||
|
||||
/**
|
||||
* @author zhaofeng_cheng
|
||||
* @date 2024/10/26 16:09
|
||||
* @description
|
||||
*/
|
||||
public interface PrintConstants {
|
||||
String DEFAULT_PRINT_QUEUE_NAME = "LabelPrint";
|
||||
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
package com.foreverwin.nlv.print.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.foreverwin.iep.common.utils.HandleBoProcessor;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zhaofeng_cheng
|
||||
* @date 2024/11/1 16:37
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@TableName("print_pda_bind")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "")
|
||||
public class PrintPdaBind extends Model<PrintPdaBind> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String KW_Z_PRINT_PDA_BIND_BO = "PrintPdaBindBO";
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value="主键")
|
||||
private String handle;
|
||||
|
||||
/**
|
||||
* site
|
||||
*/
|
||||
@ApiModelProperty(value="site")
|
||||
private String site;
|
||||
|
||||
/**
|
||||
* printId
|
||||
*/
|
||||
@ApiModelProperty(value="printId")
|
||||
private String printId;
|
||||
|
||||
/**
|
||||
* printName
|
||||
*/
|
||||
@ApiModelProperty(value="printName")
|
||||
private String printName;
|
||||
|
||||
/**
|
||||
* printIp
|
||||
*/
|
||||
@ApiModelProperty(value="printIp")
|
||||
private String printIp;
|
||||
|
||||
/**
|
||||
* pdaId
|
||||
*/
|
||||
@ApiModelProperty(value="pdaId")
|
||||
private String pdaId;
|
||||
|
||||
/**
|
||||
* pdaIp
|
||||
*/
|
||||
@ApiModelProperty(value="pdaIp")
|
||||
private String pdaIp;
|
||||
|
||||
/**
|
||||
* pdaName
|
||||
*/
|
||||
@ApiModelProperty(value="pdaName")
|
||||
private String pdaName;
|
||||
|
||||
/**
|
||||
* dateCreate
|
||||
*/
|
||||
@ApiModelProperty(value="dateCreate")
|
||||
private LocalDateTime dateCreate;
|
||||
|
||||
/**
|
||||
* creator
|
||||
*/
|
||||
@ApiModelProperty(value="creator")
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* dateUpdate
|
||||
*/
|
||||
@ApiModelProperty(value="dateUpdate")
|
||||
private LocalDateTime dateUpdate;
|
||||
|
||||
/**
|
||||
* updater
|
||||
*/
|
||||
@ApiModelProperty(value="updater")
|
||||
private String updater;
|
||||
|
||||
|
||||
public static String genHandle(String site, String printId, String pdaId) {
|
||||
return HandleBoProcessor.genHandle(KW_Z_PRINT_PDA_BIND_BO, site, printId, pdaId);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.foreverwin.nlv.print.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhaofeng_cheng
|
||||
* @date 2024/10/29 16:17
|
||||
* @description
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class PrintRequest implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private @NotEmpty String site;
|
||||
private @NotEmpty String user;
|
||||
private String barcodeType;
|
||||
private @NotEmpty String barcodeNumber;
|
||||
private String shopOrder;
|
||||
private BigDecimal qty;
|
||||
private String printServer;
|
||||
private String printName;
|
||||
private int labelQty;
|
||||
private String templatePath;
|
||||
private String templateName;
|
||||
private String transactionId;
|
||||
private List<Map<String, Object>> printData;
|
||||
private JSONArray printArray;
|
||||
private String operationType;
|
||||
private String printScenario;
|
||||
private String basedataContent;
|
||||
|
||||
public PrintRequest() {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.foreverwin.nlv.print.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @program: chengzhaofeng
|
||||
* @description: 打印返回结果
|
||||
*/
|
||||
@Data
|
||||
public class PrintResult {
|
||||
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
|
||||
public PrintResult() {
|
||||
}
|
||||
|
||||
public PrintResult(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public PrintResult(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.foreverwin.nlv.print.config;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jms.core.JmsMessagingTemplate;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class PrintActiveMQConfig {
|
||||
|
||||
@Value("${spring.print.brokerUrl:tcp://192.168.100.7:61616}")
|
||||
private String url;
|
||||
@Value("${spring.print.user:admin}")
|
||||
private String user;
|
||||
@Value("${spring.print.password:admin}")
|
||||
private String password;
|
||||
|
||||
@Bean(name = "printConnectionFactory")
|
||||
public ConnectionFactory printConnectionFactory() {
|
||||
return new ActiveMQConnectionFactory(user, password, url);
|
||||
}
|
||||
|
||||
@Bean(name = "printActivemqTemplate")
|
||||
public JmsMessagingTemplate printActivemqTemplate() {
|
||||
return new JmsMessagingTemplate(printConnectionFactory());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
package com.foreverwin.nlv.print.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.foreverwin.mom.common.core.constant.SecurityConstants;
|
||||
import com.foreverwin.mom.common.core.exception.BusinessException;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
import com.foreverwin.mom.common.log.annotation.SysLog;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import com.foreverwin.nlv.print.entity.PrintPdaBind;
|
||||
import com.foreverwin.nlv.print.service.PrintPdaBindService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
* @author zhaofeng_cheng
|
||||
* @date 2024/11/1 16:45
|
||||
* @description
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/print-pda-bind" )
|
||||
@Api(value = "打印机绑定PDA", tags = "管理")
|
||||
public class PrintPdaBindController {
|
||||
|
||||
private final PrintPdaBindService printPdaBindService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param printPdaBind
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页查询", notes = "分页查询")
|
||||
@GetMapping("/page" )
|
||||
public R getPrintPdaBindPage(Page<PrintPdaBind> page, PrintPdaBind printPdaBind) {
|
||||
return R.ok(printPdaBindService.page(page, Wrappers.<PrintPdaBind>lambdaQuery().eq(PrintPdaBind::getSite, printPdaBind.getSite())
|
||||
.like(StrUtil.isNotBlank(printPdaBind.getPrintName()), PrintPdaBind::getPrintName, printPdaBind.getPrintName())
|
||||
.like(StrUtil.isNotBlank(printPdaBind.getPrintIp()), PrintPdaBind::getPrintIp, printPdaBind.getPrintIp())));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param handle id
|
||||
* @return R
|
||||
*/
|
||||
@ApiOperation(value = "通过id查询", notes = "通过id查询")
|
||||
@GetMapping("/{handle}" )
|
||||
public R getById(@PathVariable("handle" ) String handle) {
|
||||
return R.ok(printPdaBindService.getById(handle));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param printPdaBind
|
||||
* @return R
|
||||
*/
|
||||
@ApiOperation(value = "新增", notes = "新增")
|
||||
@SysLog("新增" )
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('print_pda_bind_add')" )
|
||||
public R save(@RequestBody PrintPdaBind printPdaBind) {
|
||||
String genHandle = PrintPdaBind.genHandle(printPdaBind.getSite(), printPdaBind.getPrintId(),
|
||||
printPdaBind.getPdaId());
|
||||
PrintPdaBind pdaBindServiceById = printPdaBindService.getById(genHandle);
|
||||
if (pdaBindServiceById != null) {
|
||||
throw BusinessException.build("该打印机ID已绑定PDA_ID");
|
||||
}
|
||||
printPdaBind.setHandle(genHandle);
|
||||
printPdaBind.setDateCreate(LocalDateTime.now());
|
||||
printPdaBind.setCreator(SecurityUtils.getUserName());
|
||||
return R.ok(printPdaBindService.save(printPdaBind));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param printPdaBind
|
||||
* @return R
|
||||
*/
|
||||
@ApiOperation(value = "修改", notes = "修改")
|
||||
@SysLog("修改" )
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('print_pda_bind_edit')" )
|
||||
public R updateById(@RequestBody PrintPdaBind printPdaBind) {
|
||||
printPdaBind.setDateUpdate(LocalDateTime.now());
|
||||
printPdaBind.setUpdater(SecurityUtils.getUserName());
|
||||
return R.ok(printPdaBindService.updateById(printPdaBind));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* @param handle id
|
||||
* @return R
|
||||
*/
|
||||
@ApiOperation(value = "通过id删除", notes = "通过id删除")
|
||||
@SysLog("通过id删除" )
|
||||
@DeleteMapping("/{handle}" )
|
||||
@PreAuthorize("@pms.hasPermission('print_pda_bind_del')" )
|
||||
public R removeById(@PathVariable String handle) {
|
||||
return R.ok(printPdaBindService.removeById(handle));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.foreverwin.nlv.print.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.foreverwin.nlv.print.entity.PrintPdaBind;
|
||||
|
||||
/**
|
||||
* @author zhaofeng_cheng
|
||||
* @date 2024/11/1 16:42
|
||||
* @description
|
||||
*/
|
||||
public interface PrintPdaBindService extends IService<PrintPdaBind> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.foreverwin.nlv.print.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.foreverwin.nlv.print.entity.PrintRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PrintRuleService extends IService<PrintRule> {
|
||||
|
||||
List<PrintRule> selectList(PrintRule printRule);
|
||||
|
||||
void doSave(List<PrintRule> printRuleList);
|
||||
|
||||
void doDelete(List<PrintRule> printRuleList);
|
||||
|
||||
List<Map<String,String>> getLabelCategoryList(String site);
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.foreverwin.nlv.print.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.foreverwin.nlv.print.entity.PrintRecord;
|
||||
import com.foreverwin.nlv.print.entity.PrintRequest;
|
||||
import com.foreverwin.nlv.print.entity.PrintResult;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PrintService {
|
||||
|
||||
// 获取打印机
|
||||
String getPrinter(String site,String printScenario,String operationType,String resource,String barcodeNumber);
|
||||
|
||||
// 打印
|
||||
PrintResult print(String site, String printerName, List<String> printContentList);
|
||||
|
||||
/**
|
||||
* 厚生打印方法-->已知打印机
|
||||
* @param site
|
||||
* @param user
|
||||
* @param barcodeNumber
|
||||
* @param copies 副本数量(打印份数)
|
||||
* @param operationType //工序类型 例:基膜,大分切 等
|
||||
* @param printScenario //打印场景 例:工序打印,条码补打印 等
|
||||
* @param baseData
|
||||
* @param printNumber //打印机编号
|
||||
* @return
|
||||
*/
|
||||
PrintResult doPrint(String site, String user, String customer, String barcodeNumber, int copies, String operationType, String printScenario, List<Map<String, Object>> baseData, String printNumber);
|
||||
|
||||
String savePrintLog(@Valid PrintRequest printRequest, int printTimes, int copies, PrintRecord rePrintRecord);
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.foreverwin.nlv.print.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.foreverwin.nlv.print.entity.PrintPdaBind;
|
||||
import com.foreverwin.nlv.print.mapper.PrintPdaBindMapper;
|
||||
import com.foreverwin.nlv.print.service.PrintPdaBindService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author zhaofeng_cheng
|
||||
* @date 2024/11/1 16:43
|
||||
* @description
|
||||
*/
|
||||
@Service
|
||||
public class PrintPdaBindServiceImpl extends ServiceImpl<PrintPdaBindMapper, PrintPdaBind> implements PrintPdaBindService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package com.foreverwin.nlv.print.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.foreverwin.nlv.print.entity.PrintRule;
|
||||
import com.foreverwin.nlv.print.mapper.PrintRuleMapper;
|
||||
import com.foreverwin.nlv.print.service.PrintRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class PrintRuleServiceImpl extends ServiceImpl<PrintRuleMapper, PrintRule> implements PrintRuleService {
|
||||
|
||||
@Autowired
|
||||
private PrintRuleMapper printRuleMapper;
|
||||
|
||||
@Override
|
||||
public List<PrintRule> selectList(PrintRule printRule) {
|
||||
QueryWrapper<PrintRule> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.setEntity(printRule);
|
||||
return super.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSave(List<PrintRule> printRuleList) {
|
||||
LocalDateTime time = LocalDateTime.now();
|
||||
for(PrintRule printRule: printRuleList){
|
||||
PrintRule message = new PrintRule();
|
||||
message.setHandle(printRule.getHandle());
|
||||
QueryWrapper<PrintRule> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.setEntity(message);
|
||||
super.remove(queryWrapper);
|
||||
|
||||
printRule.setCreatedDateTime(time);
|
||||
super.save(printRule);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doDelete(List<PrintRule> printRuleList) {
|
||||
for(PrintRule printRule: printRuleList){
|
||||
QueryWrapper<PrintRule> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.setEntity(printRule);
|
||||
super.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> getLabelCategoryList(String site) {
|
||||
return printRuleMapper.selectLabelCategory(site);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,582 @@
|
||||
package com.foreverwin.nlv.print.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.foreverwin.mom.common.core.exception.BusinessException;
|
||||
import com.foreverwin.nlv.print.constant.PrintConstants;
|
||||
import com.foreverwin.nlv.print.entity.LabelFieldAllocation;
|
||||
import com.foreverwin.nlv.print.entity.LabelFieldAllocationDetail;
|
||||
import com.foreverwin.nlv.print.entity.PrintLabelTemplate;
|
||||
import com.foreverwin.nlv.print.entity.PrintRecord;
|
||||
import com.foreverwin.nlv.print.entity.PrintRequest;
|
||||
import com.foreverwin.nlv.print.entity.PrintResult;
|
||||
import com.foreverwin.nlv.print.entity.PrintRule;
|
||||
import com.foreverwin.nlv.print.entity.Printer;
|
||||
import com.foreverwin.nlv.print.entity.SystemField;
|
||||
import com.foreverwin.nlv.print.mapper.PrintRecordMapper;
|
||||
import com.foreverwin.nlv.print.mapper.PrinterMapper;
|
||||
import com.foreverwin.nlv.print.mapper.SystemFieldMapper;
|
||||
import com.foreverwin.nlv.print.service.LabelFieldAllocationService;
|
||||
import com.foreverwin.nlv.print.service.PrintLabelTemplateService;
|
||||
import com.foreverwin.nlv.print.service.PrintRecordService;
|
||||
import com.foreverwin.nlv.print.service.PrintRuleService;
|
||||
import com.foreverwin.nlv.print.service.PrintService;
|
||||
import com.foreverwin.nlv.print.service.PrinterService;
|
||||
import com.foreverwin.nlv.print.service.SystemFieldService;
|
||||
import com.foreverwin.nlv.print.util.StringUtil;
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.jms.core.JmsMessagingTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zhaofeng_cheng
|
||||
* @date 2024/10/26 15:56
|
||||
* @description
|
||||
*/
|
||||
@Service
|
||||
public class PrintServiceImpl implements PrintService {
|
||||
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private PrinterMapper printerMapper;
|
||||
|
||||
@Autowired
|
||||
private SystemFieldMapper systemFieldMapper;
|
||||
|
||||
@Autowired
|
||||
private PrinterService printerService;
|
||||
|
||||
@Autowired
|
||||
private PrintRuleService printRuleService;
|
||||
|
||||
@Autowired
|
||||
private PrintRecordMapper printRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private PrintRecordService printRecordService;
|
||||
|
||||
@Autowired
|
||||
private PrintLabelTemplateService printLabelTemplateService;
|
||||
|
||||
@Autowired
|
||||
private LabelFieldAllocationService labelFieldAllocationService;
|
||||
|
||||
@Autowired
|
||||
private SystemFieldService systemFieldService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("printActivemqTemplate")
|
||||
private JmsMessagingTemplate jmsTemplate;
|
||||
|
||||
/**
|
||||
* 获取打印机
|
||||
*
|
||||
* @param site
|
||||
* @param printScenario
|
||||
* @param operationType
|
||||
* @param resource
|
||||
* @param barcodeNumber
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinter(String site, String printScenario, String operationType, String resource,
|
||||
String barcodeNumber) {
|
||||
//获取打印机
|
||||
List<String> printerList = getPrinterByPrintScenario(site, printScenario, operationType, resource,
|
||||
barcodeNumber);
|
||||
if (printerList.isEmpty()) {
|
||||
throw BusinessException.build("未获取到打印机,请在【打印机注册】功能中确认是否有配置");
|
||||
} else if (printerList.size() > 1) {
|
||||
throw BusinessException.build("获取到多个打印机,请在【打印机注册】功能中确认配置");
|
||||
}
|
||||
|
||||
return printerList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印入口
|
||||
*
|
||||
* @param site
|
||||
* @param printerName
|
||||
* @param printContentList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PrintResult print(String site, String printerName, List<String> printContentList) {
|
||||
PrintResult printResult = new PrintResult(0);
|
||||
try {
|
||||
for (String printContent : printContentList) {
|
||||
// 使用默认打印队列名称
|
||||
String queueName = "LabelPrint";
|
||||
jmsTemplate.convertAndSend(queueName, printContent);
|
||||
String mqUrl = ((ActiveMQConnectionFactory) jmsTemplate.getConnectionFactory()).getBrokerURL();
|
||||
if (StrUtil.isNotBlank(mqUrl)) {
|
||||
mqUrl = mqUrl.substring(mqUrl.indexOf("//") + 2, mqUrl.lastIndexOf(":"));
|
||||
}
|
||||
logger.info("print success printer to ip {}:[{}], data:{}", mqUrl, printerName, printContent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
printResult.setCode(1);
|
||||
printResult.setMsg(StrUtil.isBlank(e.getMessage()) ? e.toString() : e.getMessage());
|
||||
if (printResult.getCode() == 1) {
|
||||
throw BusinessException.build(StrUtil.isBlank(e.getMessage()) ? e.toString() : e.getMessage());
|
||||
}
|
||||
}
|
||||
return printResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送打印数据
|
||||
*
|
||||
* @param site
|
||||
* @param printContent
|
||||
* @param printName
|
||||
* @param queueName
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public void processAndSendPrintData(String site, @Valid String printContent, String printName, String queueName)
|
||||
throws BusinessException {
|
||||
// 使用默认打印队列名称
|
||||
queueName = PrintConstants.DEFAULT_PRINT_QUEUE_NAME;
|
||||
jmsTemplate.convertAndSend(queueName, printContent);
|
||||
String mqUrl = ((ActiveMQConnectionFactory) jmsTemplate.getConnectionFactory()).getBrokerURL();
|
||||
if (StrUtil.isNotBlank(mqUrl)) {
|
||||
mqUrl = mqUrl.substring(mqUrl.indexOf("//") + 2, mqUrl.lastIndexOf(":"));
|
||||
}
|
||||
logger.info("print success printer to ip {}:[{}], data:{}", mqUrl, printName, printContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 依打印场景 获取打印机
|
||||
*
|
||||
* @param site
|
||||
* @param printScenario
|
||||
* @param operationType
|
||||
* @param resource
|
||||
* @param barcodeNumber
|
||||
* @return
|
||||
*/
|
||||
public List<String> getPrinterByPrintScenario(String site, String printScenario, String operationType,
|
||||
String resource, String barcodeNumber) {
|
||||
List<String> printerList = new ArrayList<>();
|
||||
//后台存储数据样式 基膜-JM
|
||||
String dbOperationType = "";
|
||||
//后台存储数据样式 工序打印-operation
|
||||
String dbPrintScenario = "";
|
||||
switch (operationType) {
|
||||
case "JM":
|
||||
dbOperationType = "基膜-JM";
|
||||
break;
|
||||
case "DFQ":
|
||||
dbOperationType = "大分切-DFQ";
|
||||
break;
|
||||
case "TF":
|
||||
dbOperationType = "涂覆-TF";
|
||||
break;
|
||||
case "XFQ":
|
||||
dbOperationType = "小分切-XFQ";
|
||||
break;
|
||||
case "JL":
|
||||
dbOperationType = "浆料-JL";
|
||||
break;
|
||||
case "BZ":
|
||||
dbOperationType = "包装-BZ";
|
||||
break;
|
||||
case "FH":
|
||||
dbOperationType = "发货-FH";
|
||||
break;
|
||||
}
|
||||
switch (printScenario) {
|
||||
case "operation":
|
||||
dbPrintScenario = "工序打印-operation";
|
||||
break;
|
||||
case "barcode":
|
||||
dbPrintScenario = "条码补打印-barcode";
|
||||
break;
|
||||
case "package":
|
||||
dbPrintScenario = "包装批次打印-package";
|
||||
break;
|
||||
case "tool":
|
||||
dbPrintScenario = "物流载具打印-tool";
|
||||
break;
|
||||
}
|
||||
if ("operation".equalsIgnoreCase(printScenario)) {
|
||||
//工序打印
|
||||
printerList = printerMapper.selectPrinter(site, dbOperationType, resource);
|
||||
} else if ("barcode".equalsIgnoreCase(printScenario)) {
|
||||
//条码补打印
|
||||
PrintRecord printRecord = printRecordMapper.selectPrintReocrdByBarcodeNumber(site, barcodeNumber);
|
||||
if (printRecord == null) {
|
||||
throw BusinessException.build("找不到条码【" + barcodeNumber + "】打印记录");
|
||||
} else if (StringUtil.isEmpty(printRecord.getPrinterName())) {
|
||||
throw BusinessException.build("条码【" + barcodeNumber + "】打印记录中打印机为空");
|
||||
} else {
|
||||
printerList.add(printRecord.getPrinterName());
|
||||
}
|
||||
} else {
|
||||
//包装批次打印、物流载具打印
|
||||
Printer printer = new Printer();
|
||||
printer.setSite(site);
|
||||
printer.setPrintScenario(dbPrintScenario);
|
||||
List<Printer> printers = printerService.selectList(printer);
|
||||
if (printers.size() > 0) {
|
||||
for (Printer p : printers) {
|
||||
printerList.add(p.getPrinterId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return printerList;
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.SUPPORTS)
|
||||
public PrintResult doPrint(String site, String user, String customer, String barcodeNumber, int copies, String operationType, String printScenario, List<Map<String, Object>> baseDataList, String printNumber) {
|
||||
|
||||
PrintResult printResult = new PrintResult(0);
|
||||
//厚生业务会存在多个打印模板的情况,而且每个模式打印次数是通过人员设置的
|
||||
List<Map<String, Object>> templateAndPrintCntMapList;
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
//获取打印模板和打印次数
|
||||
templateAndPrintCntMapList = getTemplatesByPrintScenario(site, customer, printScenario, operationType, barcodeNumber);
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
String printerName = printNumber;
|
||||
String templateName = "";
|
||||
try {
|
||||
|
||||
if ("barcode".equalsIgnoreCase(printScenario)) {
|
||||
//补打印的逻辑处理
|
||||
PrintRecord printRecord = printRecordService.getOne(Wrappers.<PrintRecord>lambdaQuery()
|
||||
.eq(PrintRecord::getSite, site)
|
||||
.eq(PrintRecord::getBarcodeNumber, barcodeNumber), false);
|
||||
|
||||
printRecord.setModifiedUser(user);
|
||||
savePrintLog(null, 1, copies, printRecord);
|
||||
|
||||
processAndSendPrintData(site, printRecord.getPrintContent(), printerName, null);
|
||||
|
||||
} else {
|
||||
|
||||
//非补打印的逻辑处理
|
||||
//依据打印模板和打印次数,统计 PrintRequest 列表
|
||||
List<PrintRequest> printRequests = new ArrayList<>();
|
||||
for (Map<String, Object> m : templateAndPrintCntMapList) {
|
||||
templateName = m.get("template").toString();
|
||||
PrintRequest printRequest = getPrintData(site, user, "", barcodeNumber, Integer.valueOf(m.get("printCount").toString()), operationType, printScenario, printerName, templateName, baseDataList);
|
||||
|
||||
if (printRequest == null) {
|
||||
throw BusinessException.build("单据【" + barcodeNumber + "】未获取到打印数据");
|
||||
}
|
||||
|
||||
printRequests.add(printRequest);
|
||||
|
||||
}
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
for (PrintRequest pr : printRequests) {
|
||||
//为便于异常时,获取到实际的模板,此时再次赋值
|
||||
templateName = pr.getTemplateName();
|
||||
// 调用doPrint的,都是直接打印,所以次数固定传1就行了。如果有记录就加1,如果没有就用传的值
|
||||
String printContent = savePrintLog(pr, 1, copies, null);
|
||||
processAndSendPrintData(site, printContent, printerName, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
printResult.setCode(1);
|
||||
printResult.setMsg(StrUtil.isBlank(e.getMessage()) ? e.toString() : e.getMessage());
|
||||
//errorMessageLogService.saveErrorMessage(site,templateName,shopOrder,user,barcodeNumber,printerName, Exceptions.getRootCauseException(e).getMessage(),user,LocalDateTime.now(),"doPrint");
|
||||
//抛出异常,事务回滚 2022/03/01
|
||||
if (printResult.getCode() == 1) {
|
||||
throw BusinessException.build(StrUtil.isBlank(e.getMessage()) ? e.toString() : e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return printResult;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getTemplatesByPrintScenario(String site, String customer, String printScenario, String operationType, String barcodeNumber) {
|
||||
//厚生业务会存在多个打印模板的情况,而且每个模式打印次数是通过人员设置的
|
||||
//数据样式 map.put("template","template001"); map.put("printCount",2)
|
||||
List<Map<String, Object>> templateAndPrintCntList = new ArrayList<>();
|
||||
|
||||
if ("operation".equalsIgnoreCase(printScenario)) {
|
||||
//****工序打印
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
|
||||
|
||||
//依客户编号及工序类型 获取客户打印规则中的规则公式(模板类别)及打印次数
|
||||
//数据格式 map.put("rule","rule001"); map.put("printCount",2)
|
||||
List<Map<String, Object>> rulePrintCntMapList = new ArrayList<>();
|
||||
PrintRule printRule = new PrintRule();
|
||||
printRule.setSite(site);
|
||||
printRule.setCustomerCode(customer);
|
||||
printRule.setOperation(operationType);
|
||||
printRule.setStatus("Y");
|
||||
List<PrintRule> printRules = printRuleService.selectList(printRule);
|
||||
if (printRules.size() < 1) {
|
||||
printRule.setCustomerCode("71001");
|
||||
printRules = printRuleService.selectList(printRule);
|
||||
if (printRules.size() < 1) {
|
||||
throw BusinessException.build("客户编号【" + customer + "】或【71001】未维护客户打印规则");
|
||||
}
|
||||
}
|
||||
|
||||
for (PrintRule pr : printRules) {
|
||||
if (!StringUtil.isEmpty(pr.getRule1())) {
|
||||
Map m1 = new HashMap();
|
||||
m1.put("rule", pr.getRule1());
|
||||
m1.put("printCount", pr.getPrintNumber1());
|
||||
rulePrintCntMapList.add(m1);
|
||||
}
|
||||
if (!StringUtil.isEmpty(pr.getRule2())) {
|
||||
Map m2 = new HashMap();
|
||||
m2.put("rule", pr.getRule2());
|
||||
m2.put("printCount", pr.getPrintNumber2());
|
||||
rulePrintCntMapList.add(m2);
|
||||
}
|
||||
if (!StringUtil.isEmpty(pr.getRule3())) {
|
||||
Map m3 = new HashMap();
|
||||
m3.put("rule", pr.getRule3());
|
||||
m3.put("printCount", pr.getPrintNumber3());
|
||||
rulePrintCntMapList.add(m3);
|
||||
}
|
||||
}
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
//依客户编号、规则公式(模板类别)及打印次数 更新最终使用的打印模板及打印次数
|
||||
PrintLabelTemplate printLabelTemplateObj = new PrintLabelTemplate();
|
||||
printLabelTemplateObj.setSite(site);
|
||||
printLabelTemplateObj.setCustomerCode(customer);
|
||||
printLabelTemplateObj.setStatus("Y");
|
||||
for (Map<String, Object> m : rulePrintCntMapList) {
|
||||
printLabelTemplateObj.setTemplateCategory(m.get("rule").toString());
|
||||
List<PrintLabelTemplate> printLabelTemplates = printLabelTemplateService.selectList(printLabelTemplateObj);
|
||||
if (printLabelTemplates.size() < 1) {
|
||||
printLabelTemplateObj.setCustomerCode("71001");
|
||||
printLabelTemplates = printLabelTemplateService.selectList(printLabelTemplateObj);
|
||||
if (printLabelTemplates.size() < 1) {
|
||||
throw BusinessException.build("客户编号【" + customer + "】或【71001】、模板类型【" + m.get("rule").toString() + "】没有启用的打印模板");
|
||||
}
|
||||
}
|
||||
|
||||
for (PrintLabelTemplate plt : printLabelTemplates) {
|
||||
Map<String, Object> templateMap = new HashMap<>();
|
||||
templateMap.put("template", plt.getTemplateCode());
|
||||
templateMap.put("printCount", m.get("printCount"));
|
||||
templateAndPrintCntList.add(templateMap);
|
||||
}
|
||||
}
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``
|
||||
|
||||
} else if ("barcode".equalsIgnoreCase(printScenario)) {
|
||||
//****条码补打印
|
||||
PrintRecord printRecord = printRecordMapper.selectPrintReocrdByBarcodeNumber(site, barcodeNumber);
|
||||
if (printRecord == null) {
|
||||
throw BusinessException.build("找不到条码【" + barcodeNumber + "】打印记录");
|
||||
}
|
||||
|
||||
Map<String, Object> templateMap = new HashMap<>();
|
||||
templateMap.put("template", printRecord.getPrintTmpl());
|
||||
templateMap.put("printCount", printRecord.getCopies());
|
||||
templateAndPrintCntList.add(templateMap);
|
||||
|
||||
} else {
|
||||
//****包装批次打印、物流载具打印
|
||||
//模板类别:原材料标签 Label001 物流载具 Label002
|
||||
String labelType = "Label001";
|
||||
if ("tool".equalsIgnoreCase(printScenario)) {
|
||||
labelType = "Label002";
|
||||
}
|
||||
if ("storageNo".equalsIgnoreCase(printScenario)) {
|
||||
labelType = "Label003";
|
||||
}
|
||||
if ("roh".equalsIgnoreCase(printScenario) || "verp".equalsIgnoreCase(printScenario)) {
|
||||
labelType = "Label004";
|
||||
}
|
||||
if ("fert".equalsIgnoreCase(printScenario)) {
|
||||
labelType = "Label005";
|
||||
}
|
||||
//依模板类别 获取最终使用的打印模板及打印次数
|
||||
PrintLabelTemplate printLabelTemplateObj = new PrintLabelTemplate();
|
||||
printLabelTemplateObj.setSite(site);
|
||||
printLabelTemplateObj.setTemplateCategory(labelType);
|
||||
printLabelTemplateObj.setStatus("Y");
|
||||
List<PrintLabelTemplate> printLabelTemplates = printLabelTemplateService.selectList(printLabelTemplateObj);
|
||||
if (printLabelTemplates.size() < 1) {
|
||||
throw BusinessException.build("模板类别【" + labelType + "】没有启用的打印模板");
|
||||
}
|
||||
for (PrintLabelTemplate plt : printLabelTemplates) {
|
||||
Map<String, Object> templateMap = new HashMap<>();
|
||||
templateMap.put("template", plt.getTemplateCode());
|
||||
templateMap.put("printCount", "1");
|
||||
templateAndPrintCntList.add(templateMap);
|
||||
}
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
|
||||
return templateAndPrintCntList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印日志存储
|
||||
* @param printRequest
|
||||
* @param printTimes
|
||||
* @param copies
|
||||
* @param rePrintRecord
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String savePrintLog(@Valid PrintRequest printRequest, int printTimes, int copies, PrintRecord rePrintRecord) {
|
||||
String printContent = "";
|
||||
if (rePrintRecord != null) {
|
||||
// 补打印,添加打印次数
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
rePrintRecord.setPrintTimes(rePrintRecord.getPrintTimes() + 1);
|
||||
rePrintRecord.setCopies(rePrintRecord.getCopies() + copies);
|
||||
rePrintRecord.setLastPrintTime(now);
|
||||
rePrintRecord.setModifiedDateTime(now);
|
||||
printRecordService.updateById(rePrintRecord);
|
||||
} else {
|
||||
// 非补打印
|
||||
JSONObject param = new JSONObject();
|
||||
JSONObject printRequestObj = new JSONObject();
|
||||
printRequestObj.put("PRINT_SERVER", printRequest.getPrintServer());
|
||||
printRequestObj.put("PRINT_NAME", printRequest.getPrintName());
|
||||
printRequestObj.put("LABEL_QTY", printRequest.getLabelQty());
|
||||
printRequestObj.put("TEMPLATE", printRequest.getTemplatePath());
|
||||
printRequestObj.put("TRANSACTION_ID", printRequest.getTransactionId());
|
||||
printRequestObj.put("PRINT_DATA", JSONObject.toJSON(printRequest.getPrintData()));
|
||||
param.put("PRINT_REQUEST", printRequestObj);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
printContent = param.toJSONString();
|
||||
PrintRecord printRecord = printRecordService.getOne(Wrappers.<PrintRecord>lambdaQuery()
|
||||
.eq(PrintRecord::getSite, printRequest.getSite())
|
||||
.eq(PrintRecord::getBarcodeNumber, printRequest.getBarcodeNumber())
|
||||
.eq(PrintRecord::getBarcodeType, printRequest.getBarcodeType())
|
||||
.eq(PrintRecord::getPrintTmpl, printRequest.getTemplateName()), false);
|
||||
if (printRecord == null) {
|
||||
printRecord = new PrintRecord();
|
||||
printRecord.setSite(printRequest.getSite());
|
||||
printRecord.setShopOrder(printRequest.getShopOrder());
|
||||
printRecord.setBarcodeNumber(printRequest.getBarcodeNumber());
|
||||
printRecord.setBarcodeType(printRequest.getBarcodeType());
|
||||
printRecord.setPrintContent(printContent);
|
||||
printRecord.setBasedataContent(printRequest.getBasedataContent());
|
||||
printRecord.setPrinterName(printRequest.getPrintName());
|
||||
printRecord.setPrintTmpl(printRequest.getTemplateName());
|
||||
printRecord.setPrintTimes(printTimes);
|
||||
printRecord.setCopies(copies);
|
||||
printRecord.setLastPrintTime(now);
|
||||
printRecord.setCreatedDateTime(now);
|
||||
printRecord.setCreatedUser(printRequest.getUser());
|
||||
printRecord.setModifiedDateTime(now);
|
||||
printRecord.setModifiedUser(printRequest.getUser());
|
||||
printRecordService.save(printRecord);
|
||||
} else {
|
||||
printRecord.setPrintContent(printContent);
|
||||
printRecord.setBasedataContent(printRequest.getBasedataContent());
|
||||
printRecord.setPrintTimes(printRecord.getPrintTimes() + 1);
|
||||
printRecord.setCopies(printRecord.getCopies() + copies);
|
||||
printRecord.setLastPrintTime(now);
|
||||
printRecord.setModifiedUser(printRequest.getUser());
|
||||
printRecord.setModifiedDateTime(now);
|
||||
printRecordService.updateById(printRecord);
|
||||
}
|
||||
}
|
||||
return printContent;
|
||||
}
|
||||
|
||||
public PrintRequest getPrintData(String site, String user, String shopOrder, String barcodeNumber, int copies, String operationType, String printScenario, String printer, String templateName, List<Map<String, Object>> baseDataList) {
|
||||
PrintRequest printRequest;
|
||||
try {
|
||||
LabelFieldAllocation labelFieldAllocation = labelFieldAllocationService.labelNumberInfo(site, templateName);
|
||||
if (labelFieldAllocation == null || labelFieldAllocation.getLabelFieldAllocationDetailList() == null || labelFieldAllocation.getLabelFieldAllocationDetailList().size() == 0) {
|
||||
throw BusinessException.build("模板编号[" + templateName + "]的模板变量关系未维护");
|
||||
}
|
||||
List<Map<String, Object>> printData = new ArrayList<>();
|
||||
List<LabelFieldAllocationDetail> detailList = labelFieldAllocation.getLabelFieldAllocationDetailList();
|
||||
List<String> fieldNumberList = new ArrayList<>();
|
||||
for (LabelFieldAllocationDetail detail : detailList) {
|
||||
fieldNumberList.add(SystemField.genHandle(site, detail.getFieldNumber()));
|
||||
}
|
||||
// 缓存所有SystemField
|
||||
Collection<SystemField> systemFieldList = systemFieldService.listByIds(fieldNumberList);
|
||||
Map<String, SystemField> systemFieldMap = systemFieldList.stream().collect(
|
||||
Collectors.toMap(SystemField::getFieldNumber, a -> a, (key1, key2) -> key2));
|
||||
long current = System.currentTimeMillis();
|
||||
for (Map<String, Object> baseData:baseDataList){
|
||||
Map<String, Object> printDataMap = new HashMap<>();
|
||||
for (LabelFieldAllocationDetail detail : detailList) {
|
||||
String templateField = detail.getLabelField(); // 打印服务器上标签样式里的控件的变量名
|
||||
String fieldNumber = detail.getFieldNumber(); // 系统字段
|
||||
|
||||
long current1 = System.currentTimeMillis();
|
||||
List<String> fieldValues = systemFieldService.getSystemFieldValue(site, fieldNumber, systemFieldMap, baseData);
|
||||
System.out.println("system field [" + fieldNumber + "] costs:" + (System.currentTimeMillis() - current1));
|
||||
String fieldValue = fieldValues == null || fieldValues.size() == 0 ? "" : String.join(",", fieldValues);
|
||||
SystemField systemFieldById = systemFieldService.getById(SystemField.genHandle(site, detail.getFieldNumber()));
|
||||
if (StrUtil.isBlank(fieldValue)) {
|
||||
throw BusinessException.build("标签[" + templateName + "]字段[" + templateField + "]" + systemFieldById.getFieldDescription() + "获取为空");
|
||||
}
|
||||
|
||||
//固定值为EMPTY的特殊处理
|
||||
if (fieldValue.indexOf("3_EMPTY") > -1) {
|
||||
fieldValue = "";
|
||||
}
|
||||
|
||||
//包装标签34个Field的特殊处理
|
||||
if (fieldValue.indexOf("FIELD_EMPTY") > -1) {
|
||||
fieldValue = "";
|
||||
}
|
||||
printDataMap.put(templateField, fieldValue);
|
||||
}
|
||||
System.out.println("system field cost time:" + (System.currentTimeMillis() - current));
|
||||
printData.add(printDataMap);
|
||||
}
|
||||
|
||||
|
||||
printRequest = new PrintRequest();
|
||||
printRequest.setSite(site);
|
||||
printRequest.setUser(user);
|
||||
printRequest.setPrintServer("");
|
||||
printRequest.setPrintName(printer);
|
||||
printRequest.setOperationType(operationType);
|
||||
printRequest.setLabelQty(Math.toIntExact(copies));
|
||||
printRequest.setTemplateName(templateName);
|
||||
printRequest.setTemplatePath(templateName + ".lab");
|
||||
printRequest.setTransactionId(UUID.randomUUID().toString());
|
||||
printRequest.setShopOrder(shopOrder);
|
||||
printRequest.setBarcodeNumber(barcodeNumber);
|
||||
printRequest.setBarcodeType(printScenario);
|
||||
printRequest.setPrintData(printData);
|
||||
printRequest.setBasedataContent(JSONObject.toJSONString(baseDataList));
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.build(StrUtil.isBlank(e.getMessage()) ? e.toString() : e.getMessage());
|
||||
}
|
||||
return printRequest;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.foreverwin.nlv.print.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.foreverwin.iep.sys.entity.FastCodeDetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author syngna
|
||||
* @since 2021-07-05
|
||||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface PrintFastCodeDetailMapper extends BaseMapper<FastCodeDetail> {
|
||||
|
||||
List<FastCodeDetail> getByCode(@Param("site") String site, @Param("fastCode") String fastCode, @Param("code") String code);
|
||||
|
||||
List<FastCodeDetail> getByFastCode(@Param("site") String site, @Param("fastCode") String fastCode);
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.foreverwin.nlv.print.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.foreverwin.iep.sys.dto.FastCodeDTO;
|
||||
import com.foreverwin.iep.sys.entity.FastCode;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author syngna
|
||||
* @since 2021-07-05
|
||||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface PrintFastCodeMapper extends BaseMapper<FastCode> {
|
||||
|
||||
List<FastCodeDTO> listFastCodeDetailsByFastCode(@Param("site") String site, @Param("fastCode") String fastCode, @Param("enabled") Boolean enabled);
|
||||
|
||||
Integer getExportExcelMaxRow(@Param("site") String site);
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.foreverwin.nlv.print.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.foreverwin.nlv.print.entity.PrintPdaBind;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author zhaofeng_cheng
|
||||
* @date 2024/11/1 16:40
|
||||
* @description
|
||||
*/
|
||||
@Mapper
|
||||
public interface PrintPdaBindMapper extends BaseMapper<PrintPdaBind> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.foreverwin.nlv.print.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.foreverwin.nlv.print.entity.PrintRule;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface PrintRuleMapper extends BaseMapper<PrintRule> {
|
||||
List<Map<String,String>> selectLabelCategory(@Param("site") String site);
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.foreverwin.nlv.print.mapper.PrintFastCodeDetailMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.foreverwin.iep.sys.entity.FastCodeDetail">
|
||||
<id column="HANDLE" property="handle" />
|
||||
<result column="SITE" property="site" />
|
||||
<result column="FAST_CODE_BO" property="fastCodeBo" />
|
||||
<result column="CODE" property="code" />
|
||||
<result column="MEANING" property="meaning" />
|
||||
<result column="DESCRIPTION" property="description" />
|
||||
<result column="TAG" property="tag" />
|
||||
<result column="ENABLE" property="enable" />
|
||||
<result column="EF1" property="ef1" />
|
||||
<result column="EF2" property="ef2" />
|
||||
<result column="EF3" property="ef3" />
|
||||
<result column="EF4" property="ef4" />
|
||||
<result column="EF5" property="ef5" />
|
||||
<result column="EF6" property="ef6" />
|
||||
<result column="EF7" property="ef7" />
|
||||
<result column="EF8" property="ef8" />
|
||||
<result column="EF9" property="ef9" />
|
||||
<result column="EF10" property="ef10" />
|
||||
<result column="EF11" property="ef11" />
|
||||
<result column="EF12" property="ef12" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
HANDLE, SITE, FAST_CODE_BO, CODE, MEANING, DESCRIPTION, TAG, ENABLE, EF1, EF2, EF3, EF4, EF5, EF6, EF7, EF8, EF9, EF10, EF11, EF12
|
||||
</sql>
|
||||
|
||||
<select id="getByCode" resultMap="BaseResultMap">
|
||||
SELECT FCD.HANDLE, FCD.SITE, FCD.FAST_CODE_BO, FCD.CODE, FCD.MEANING, FCD.DESCRIPTION, FCD.TAG, FCD.ENABLE, FCD.EF1, FCD.EF2, FCD.EF3, FCD.EF4, FCD.EF5, FCD.EF6, FCD.EF7, FCD.EF8, FCD.EF9, FCD.EF10, FCD.EF11, FCD.EF12
|
||||
FROM FAST_CODE FC
|
||||
INNER JOIN FAST_CODE_DETAIL FCD
|
||||
ON FC.HANDLE = FCD.FAST_CODE_BO
|
||||
WHERE FC.SITE = #{site}
|
||||
AND FC.FAST_CODE = #{fastCode}
|
||||
AND FCD.CODE = #{code}
|
||||
</select>
|
||||
|
||||
<!-- 根据快码获取明细内容 -->
|
||||
<select id="getByFastCode" resultMap="BaseResultMap">
|
||||
SELECT FCD.HANDLE, FCD.SITE, FCD.FAST_CODE_BO, FCD.CODE, FCD.MEANING, FCD.DESCRIPTION, FCD.TAG, FCD.ENABLE, FCD.EF1, FCD.EF2, FCD.EF3, FCD.EF4, FCD.EF5, FCD.EF6, FCD.EF7, FCD.EF8, FCD.EF9, FCD.EF10, FCD.EF11, FCD.EF12
|
||||
FROM FAST_CODE FC
|
||||
INNER JOIN FAST_CODE_DETAIL FCD
|
||||
ON FC.HANDLE = FCD.FAST_CODE_BO
|
||||
WHERE FC.SITE = #{site}
|
||||
AND FC.FAST_CODE = #{fastCode}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.foreverwin.nlv.print.mapper.PrintFastCodeMapper">
|
||||
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.foreverwin.iep.sys.entity.FastCode">
|
||||
<id column="HANDLE" property="handle" />
|
||||
<result column="SITE" property="site" />
|
||||
<result column="FAST_CODE" property="fastCode" />
|
||||
<result column="DESCRIPTION" property="description" />
|
||||
<result column="CREATED_DATE_TIME" property="createdDateTime" />
|
||||
<result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
|
||||
<result column="CREATER" property="creater" />
|
||||
<result column="UPDATER" property="updater" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
HANDLE, SITE, FAST_CODE, DESCRIPTION, CREATED_DATE_TIME, MODIFIED_DATE_TIME, CREATER, UPDATER
|
||||
</sql>
|
||||
|
||||
|
||||
<resultMap id="FullResultMap" extends="BaseResultMap" type="com.foreverwin.iep.sys.dto.FastCodeDTO">
|
||||
<result column="CODE" property="code" />
|
||||
<result column="MEANING" property="meaning" />
|
||||
<result column="CODEDESC" property="codeDesc" />
|
||||
<result column="TAG" property="tag" />
|
||||
<result column="ENABLE" property="enable" />
|
||||
<result column="EF1" property="ef1" />
|
||||
<result column="EF2" property="ef2" />
|
||||
<result column="EF3" property="ef3" />
|
||||
<result column="EF4" property="ef4" />
|
||||
<result column="EF5" property="ef5" />
|
||||
<result column="EF6" property="ef6" />
|
||||
<result column="EF7" property="ef7" />
|
||||
<result column="EF8" property="ef8" />
|
||||
<result column="EF9" property="ef9" />
|
||||
<result column="EF10" property="ef10" />
|
||||
<result column="EF11" property="ef11" />
|
||||
<result column="EF12" property="ef12" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="listFastCodeDetailsByFastCode" resultMap="FullResultMap">
|
||||
SELECT FC.HANDLE,FC.SITE,FC.FAST_CODE,FC.DESCRIPTION,FCD.CODE,FCD.DESCRIPTION CODEDESC,FCD.MEANING,FCD.TAG,FCD.ENABLE,FCD.EF1,FCD.EF2,FCD.EF3,FCD.EF4,FCD.EF5,FCD.EF6,FCD.EF7,FCD.EF8,FCD.EF9,FCD.EF10,FCD.EF11,FCD.EF12
|
||||
FROM FAST_CODE FC
|
||||
LEFT JOIN FAST_CODE_DETAIL FCD ON FC.HANDLE=FCD.FAST_CODE_BO
|
||||
WHERE FC.FAST_CODE=#{fastCode}
|
||||
AND FC.SITE=#{site}
|
||||
<if test="enabled!=null and enabled==true">
|
||||
AND FCD.ENABLE='Y'
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getExportExcelMaxRow" resultType="java.lang.Integer">
|
||||
SELECT FCD.EF1
|
||||
FROM FAST_CODE FC
|
||||
INNER JOIN FAST_CODE_DETAIL FCD ON FC.HANDLE = FCD.FAST_CODE_BO AND FCD.CODE = 'MAX_ROW'
|
||||
WHERE FC.SITE = #{site} AND FC.FAST_CODE = 'REPORT_PARAM' LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.foreverwin.nlv.print.mapper.PrintPdaBindMapper">
|
||||
|
||||
<resultMap id="printPdaBindMap" type="com.foreverwin.nlv.print.entity.PrintPdaBind">
|
||||
<id property="handle" column="HANDLE"/>
|
||||
<result property="site" column="SITE"/>
|
||||
<result property="printId" column="PRINT_ID"/>
|
||||
<result property="printName" column="PRINT_NAME"/>
|
||||
<result property="printIp" column="PRINT_IP"/>
|
||||
<result property="pdaId" column="PDA_ID"/>
|
||||
<result property="pdaIp" column="PDA_IP"/>
|
||||
<result property="pdaName" column="PDA_NAME"/>
|
||||
<result property="dateCreate" column="DATE_CREATE"/>
|
||||
<result property="creator" column="CREATOR"/>
|
||||
<result property="dateUpdate" column="DATE_UPDATE"/>
|
||||
<result property="updater" column="UPDATER"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
30
print-db/src/main/resources/print/mapper/PrintRuleMapper.xml
Normal file
30
print-db/src/main/resources/print/mapper/PrintRuleMapper.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.foreverwin.nlv.print.mapper.PrintRuleMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.foreverwin.nlv.print.entity.PrintRule">
|
||||
<id column="HANDLE" property="handle" />
|
||||
<result column="SITE" property="site" />
|
||||
<result column="CUSTOMER_CODE" property="customerCode" />
|
||||
<result column="OPERATION" property="operation" />
|
||||
<result column="STATUS" property="status" />
|
||||
<result column="RULE1" property="rule1" />
|
||||
<result column="PRINT_NUMBER1" property="printNumber1" />
|
||||
<result column="RULE2" property="rule2" />
|
||||
<result column="PRINT_NUMBER2" property="printNumber2" />
|
||||
<result column="RULE3" property="rule3" />
|
||||
<result column="PRINT_NUMBER3" property="printNumber3" />
|
||||
<result column="CREATED_DATE_TIME" property="createdDateTime" />
|
||||
<result column="CREATED_USER" property="createdUser" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
HANDLE, SITE, CUSTOMER_CODE, OPERATION, STATUS, RULE1, PRINT_NUMBER1, RULE2, PRINT_NUMBER2, RULE3, PRINT_NUMBER3, CREATED_DATE_TIME, CREATED_USER
|
||||
</sql>
|
||||
<!-- 查询模板类别 -->
|
||||
<select id="selectLabelCategory" resultType="java.util.LinkedHashMap">
|
||||
SELECT LABEL_CATEGORY_ID,LABEL_CATEGORY_NAME FROM Z_LABELCATEGORY WHERE SITE=#{site}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user