change - 原材料条码信息添加
parent
3b66195f8c
commit
c6c02813c9
@ -0,0 +1,29 @@
|
|||||||
|
package com.hw.printer.api;
|
||||||
|
|
||||||
|
import com.hw.common.core.constant.SecurityConstants;
|
||||||
|
import com.hw.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.hw.common.core.domain.R;
|
||||||
|
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
|
||||||
|
import com.hw.printer.api.factory.RemotePrinterFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
|
@FeignClient(contextId = "remotePrinterService", value = ServiceNameConstants.PRINTER_SERVICE, fallbackFactory = RemotePrinterFallbackFactory.class)
|
||||||
|
public interface RemotePrinterService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过条码查询条码信息
|
||||||
|
*
|
||||||
|
* @param barcodeInfo 条码信息
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/printService/printBarCode")
|
||||||
|
public MesBaseBarcodeInfo printBarCode(@RequestBody MesBaseBarcodeInfo barcodeInfo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.hw.printer.api.factory;
|
||||||
|
|
||||||
|
import com.hw.common.core.domain.R;
|
||||||
|
|
||||||
|
import com.hw.common.core.exception.ServiceException;
|
||||||
|
import com.hw.printer.api.RemotePrinterService;
|
||||||
|
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机服务降级处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemotePrinterFallbackFactory implements FallbackFactory<RemotePrinterService> {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemotePrinterFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemotePrinterService create(final Throwable throwable) {
|
||||||
|
log.error("打印条码服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemotePrinterService() {
|
||||||
|
@Override
|
||||||
|
public MesBaseBarcodeInfo printBarCode(MesBaseBarcodeInfo barcodeInfo, String source) {
|
||||||
|
throw new ServiceException("打印条码服务调用异常:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
com.hw.mes.api.factory.RemoteMesFallbackFactory
|
@ -1,19 +0,0 @@
|
|||||||
package com.hw;
|
|
||||||
|
|
||||||
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
|
|
||||||
// then press Enter. You can now see whitespace characters in your code.
|
|
||||||
public class Main {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// Press Alt+Enter with your caret at the highlighted text to see how
|
|
||||||
// IntelliJ IDEA suggests fixing it.
|
|
||||||
System.out.printf("Hello and welcome!");
|
|
||||||
|
|
||||||
// Press Shift+F10 or click the green arrow button in the gutter to run the code.
|
|
||||||
for (int i = 1; i <= 5; i++) {
|
|
||||||
|
|
||||||
// Press Shift+F9 to start debugging your code. We have set one breakpoint
|
|
||||||
// for you, but you can always add more by pressing Ctrl+F8.
|
|
||||||
System.out.println("i = " + i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.hw.printer;
|
||||||
|
|
||||||
|
import com.hw.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件服务
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
|
||||||
|
public class RuoYiPrinterApplication
|
||||||
|
{
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
SpringApplication.run(RuoYiPrinterApplication.class, args);
|
||||||
|
System.out.println("(♥◠‿◠)ノ゙ 文件服务模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||||
|
" .-------. ____ __ \n" +
|
||||||
|
" | _ _ \\ \\ \\ / / \n" +
|
||||||
|
" | ( ' ) | \\ _. / ' \n" +
|
||||||
|
" |(_ o _) / _( )_ .' \n" +
|
||||||
|
" | (_,_).' __ ___(_ o _)' \n" +
|
||||||
|
" | |\\ \\ | || |(_,_)' \n" +
|
||||||
|
" | | \\ `' /| `-' / \n" +
|
||||||
|
" | | \\ / \\ / \n" +
|
||||||
|
" ''-' `'-' `-..-' ");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.hw.printer.controller;
|
||||||
|
|
||||||
|
import com.hw.common.core.domain.R;
|
||||||
|
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
|
||||||
|
import com.hw.printer.service.IPrinterService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机请求处理
|
||||||
|
*
|
||||||
|
* @author Yinq
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/printService")
|
||||||
|
public class PrinterController {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(PrinterController.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPrinterService printerService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印条码接口
|
||||||
|
* @param barcodeInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/printBarCode")
|
||||||
|
public R<MesBaseBarcodeInfo> printBarCode(@RequestBody MesBaseBarcodeInfo barcodeInfo) {
|
||||||
|
try {
|
||||||
|
return R.ok(printerService.printBarCode(barcodeInfo));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("打印条码失败", e);
|
||||||
|
return R.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.hw.printer.service;
|
||||||
|
|
||||||
|
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机服务接口
|
||||||
|
*
|
||||||
|
* @author Yinq
|
||||||
|
*/
|
||||||
|
public interface IPrinterService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印条码接口
|
||||||
|
* @param barcodeInfo
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
MesBaseBarcodeInfo printBarCode(MesBaseBarcodeInfo barcodeInfo) throws Exception;
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.hw.printer.service;
|
||||||
|
|
||||||
|
import com.hw.common.core.utils.DateUtils;
|
||||||
|
import com.hw.common.core.utils.StringUtils;
|
||||||
|
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
|
||||||
|
import com.hw.printer.utils.HwPrintUtil;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机服务Service
|
||||||
|
*
|
||||||
|
* @author Yinq
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PrinterServiceImpl implements IPrinterService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机映射路径
|
||||||
|
*/
|
||||||
|
@Value("${print.path}")
|
||||||
|
public String localPrintPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDF模板路径
|
||||||
|
*/
|
||||||
|
@Value("${print.pdfTemplatePath}")
|
||||||
|
public String pdfTemplatePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成PDF文件路径
|
||||||
|
*/
|
||||||
|
@Value("${print.generatePath}")
|
||||||
|
public String generatePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印条码接口
|
||||||
|
*
|
||||||
|
* @param barcodeInfo
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MesBaseBarcodeInfo printBarCode(MesBaseBarcodeInfo barcodeInfo) throws Exception {
|
||||||
|
HashMap<String, String> params = new HashMap<>();
|
||||||
|
params.put("localPrintPath", localPrintPath);
|
||||||
|
params.put("pdfTemplatePath", pdfTemplatePath);
|
||||||
|
params.put("generatePath", generatePath);
|
||||||
|
params.put("barcodeInfo", barcodeInfo.getBarcodeInfo());
|
||||||
|
params.put("batchCode", barcodeInfo.getBatchCode());
|
||||||
|
params.put("materialName", barcodeInfo.getMaterialName());
|
||||||
|
params.put("date", DateUtils.getDate());
|
||||||
|
String machineName = HwPrintUtil.printBarCode(params);
|
||||||
|
barcodeInfo.setMaterialName(machineName);
|
||||||
|
return barcodeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,6 @@
|
|||||||
Spring Boot Version: ${spring-boot.version}
|
Spring Boot Version: ${spring-boot.version}
|
||||||
Spring Application Name: ${spring.application.name}
|
Spring Application Name: ${spring.application.name}
|
||||||
_ _
|
/ __ ___ __ ( ) __ __ ___ ___ __
|
||||||
(_) | |
|
// ) ) // / / / / ____ // ) ) // ) ) / / // ) ) / / //___) ) // ) )
|
||||||
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
|
// / / // / / / / //___/ / // / / // / / / / // //
|
||||||
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
|
// / / ((__( (__/ / // // / / // / / / / ((____ //
|
||||||
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|
|
||||||
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
|
|
||||||
__/ | __/ |
|
|
||||||
|___/ |___/
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue