From 038db5ee8da7603db64dd2bc787467809b89deb7 Mon Sep 17 00:00:00 2001 From: "usama.jameel" Date: Tue, 21 Jan 2025 16:11:00 +0500 Subject: [PATCH 1/2] add dev and prod yml file and change the printer ip --- .../service/BarcodeService.java | 2 +- src/main/resources/application-dev.yml | 66 ++++++++++++++++++ src/main/resources/application-prod.yml | 66 ++++++++++++++++++ src/main/resources/application.yaml | 68 +------------------ 4 files changed, 136 insertions(+), 66 deletions(-) create mode 100644 src/main/resources/application-dev.yml create mode 100644 src/main/resources/application-prod.yml diff --git a/src/main/java/com/utopiaindustries/service/BarcodeService.java b/src/main/java/com/utopiaindustries/service/BarcodeService.java index b7ee32d..05b1cba 100644 --- a/src/main/java/com/utopiaindustries/service/BarcodeService.java +++ b/src/main/java/com/utopiaindustries/service/BarcodeService.java @@ -123,7 +123,7 @@ public class BarcodeService { } public void printLabel( BufferedImage bufferedImage ) throws Exception { - String ipAddr = "192.168.90.160"; + String ipAddr = "172.16.53.32"; int port = 9100; Connection connection = new TcpConnection( ipAddr, port ); connection.open(); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..f737fe4 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,66 @@ +spring: + resources: + chain: + cache: false + strategy: + content: + enabled: true + paths: /** + html-application-cache: true + enabled: true + cache: + period: 0 + static-locations: classpath:/static/ + thymeleaf: + check-template-location: true + cache: false + prefix: classpath:/templates/ + uinddatasource: + jdbcUrl: jdbc:mysql://192.168.90.147:3306 + username: utopia + password: Utopia01 + driverClassName: com.mysql.cj.jdbc.Driver + logbackUrl: jdbc:mysql://192.168.90.147:3306/uind_logs?serverTimezone=Asia/Karachi + hikari: + maximum-pool-size: 5 + pool-name: UINDMainPool + leak-detection-threshold: 2000 + cosmosdatasource: + jdbcUrl: jdbc:mysql://192.168.90.147:3307 + username: utopia + password: Utopia01 + driverClassName: com.mysql.cj.jdbc.Driver + hikari: + maximum-pool-size: 5 + pool-name: UINDCosmosPool + leak-detection-threshold: 2000 + localdatasource: + jdbcUrl: jdbc:mysql://192.168.90.147:3306/cut_to_pack + username: utopia + password: Utopia01 + driverClassName: com.mysql.cj.jdbc.Driver + hikari: + maximum-pool-size: 5 + pool-name: CTPPool + leak-detection-threshold: 2000 + +server: + servlet: + context-path: /ctp + tomcat: + remoteip: + remote-ip-header: X-FORWARDED-FOR + max-parameter-count: 50000 + port: 8080 + compression: + enabled: true + mime-types: text/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/json, application/xml + min-response-size: 2KB + +thymeleaf-layout-dialect: + version: 2.1.1 + +ctp: + cipher: + key: BC87A69BFCEC4A71E73B8DCCC4F14 + seed-value : 7XYXo8Qq6D \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..2e50966 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,66 @@ +spring: + resources: + chain: + cache: false + strategy: + content: + enabled: true + paths: /** + html-application-cache: true + enabled: true + cache: + period: 0 + static-locations: classpath:/static/ + thymeleaf: + check-template-location: true + cache: false + prefix: classpath:/templates/ + uinddatasource: + jdbcUrl: jdbc:mysql://localhost:3306 + username: root + password: Utopia01 + driverClassName: com.mysql.cj.jdbc.Driver + logbackUrl: jdbc:mysql://localhost:3306/uind_logs?serverTimezone=Asia/Karachi + hikari: + maximum-pool-size: 5 + pool-name: UINDMainPool + leak-detection-threshold: 2000 + cosmosdatasource: + jdbcUrl: jdbc:mysql://localhost:3307 + username: root + password: Utopia01 + driverClassName: com.mysql.cj.jdbc.Driver + hikari: + maximum-pool-size: 5 + pool-name: UINDCosmosPool + leak-detection-threshold: 2000 + localdatasource: + jdbcUrl: jdbc:mysql://localhost:3306/cut_to_pack + username: root + password: Utopia01 + driverClassName: com.mysql.cj.jdbc.Driver + hikari: + maximum-pool-size: 5 + pool-name: CTPPool + leak-detection-threshold: 2000 + +server: + servlet: + context-path: /ctp + tomcat: + remoteip: + remote-ip-header: X-FORWARDED-FOR + max-parameter-count: 50000 + port: 8080 + compression: + enabled: true + mime-types: text/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/json, application/xml + min-response-size: 2KB + +thymeleaf-layout-dialect: + version: 2.1.1 + +ctp: + cipher: + key: BC87A69BFCEC4A71E73B8DCCC4F14 + seed-value : 7XYXo8Qq6D \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 3d84f5b..b472387 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -1,70 +1,8 @@ application: title: Cut To Pack Service version: v1.0 + name: application-dev spring: - resources: - chain: - cache: false - strategy: - content: - enabled: true - paths: /** - html-application-cache: true - enabled: true - cache: - period: 0 - static-locations: classpath:/static/ - thymeleaf: - check-template-location: true - cache: false - prefix: classpath:/templates/ - uinddatasource: - jdbcUrl: jdbc:mysql://192.168.90.108:3306/uind_vms - username: utopia - password: Utopia01 - driverClassName: com.mysql.cj.jdbc.Driver - logbackUrl: jdbc:mysql://192.168.90.108:3306/uind_logs?serverTimezone=Asia/Karachi - hikari: - maximum-pool-size: 5 - pool-name: UINDMainPool - leak-detection-threshold: 2000 - cosmosdatasource: - jdbcUrl: jdbc:mysql://192.168.90.108:3307 - username: utopia - password: Utopia01 - driverClassName: com.mysql.cj.jdbc.Driver - hikari: - maximum-pool-size: 5 - pool-name: UINDCosmosPool - leak-detection-threshold: 2000 - localdatasource: - jdbcUrl: jdbc:mysql://192.168.90.108:3306/cut_to_pack - username: utopia - password: Utopia01 - driverClassName: com.mysql.cj.jdbc.Driver - hikari: - maximum-pool-size: 5 - pool-name: CTPPool - leak-detection-threshold: 2000 - -server: - servlet: - context-path: /ctp - tomcat: - remoteip: - remote-ip-header: X-FORWARDED-FOR - max-parameter-count: 50000 - port: 8080 - compression: - enabled: true - mime-types: text/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/json, application/xml - min-response-size: 2KB - -thymeleaf-layout-dialect: - version: 2.1.1 - -ctp: - cipher: - key: BC87A69BFCEC4A71E73B8DCCC4F14 - seed-value : 7XYXo8Qq6D \ No newline at end of file + profiles: + active: dev -- 2.40.1 From c8b13746880e72ca985c671f623b098d95c86909 Mon Sep 17 00:00:00 2001 From: "usama.jameel" Date: Tue, 21 Jan 2025 17:01:16 +0500 Subject: [PATCH 2/2] fixed new user error and properties --- .../com/utopiaindustries/dao/ctp/UserDAO.java | 2 +- .../service/BarcodeService.java | 11 ++++-- src/main/resources/application-dev.yml | 38 ++----------------- src/main/resources/application-prod.yml | 38 ++----------------- src/main/resources/application.yaml | 38 +++++++++++++++++++ 5 files changed, 53 insertions(+), 74 deletions(-) diff --git a/src/main/java/com/utopiaindustries/dao/ctp/UserDAO.java b/src/main/java/com/utopiaindustries/dao/ctp/UserDAO.java index d5f7693..401f31b 100644 --- a/src/main/java/com/utopiaindustries/dao/ctp/UserDAO.java +++ b/src/main/java/com/utopiaindustries/dao/ctp/UserDAO.java @@ -38,7 +38,7 @@ public class UserDAO { return namedParameterJdbcTemplate.query( SELECT_BY_USERNAME, params, new UserRowMapper() ) .stream() .findAny() - .orElse( new User() ); + .orElse( null ); } public List findAll() { diff --git a/src/main/java/com/utopiaindustries/service/BarcodeService.java b/src/main/java/com/utopiaindustries/service/BarcodeService.java index 05b1cba..27a52a0 100644 --- a/src/main/java/com/utopiaindustries/service/BarcodeService.java +++ b/src/main/java/com/utopiaindustries/service/BarcodeService.java @@ -13,6 +13,7 @@ import com.zebra.sdk.comm.TcpConnection; import com.zebra.sdk.graphics.internal.ZebraImage; import com.zebra.sdk.printer.ZebraPrinter; import com.zebra.sdk.printer.ZebraPrinterFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.imageio.ImageIO; @@ -27,6 +28,12 @@ import java.util.List; @Service public class BarcodeService { + @Value("${ctp.printer.ipAdd}") + private String ipAddress; + + @Value("${ctp.printer.port}") + private int port; + private final BundleDAO bundleDAO; private final MasterBundleDAO masterBundleDAO; private final FinishedItemDAO finishedItemDAO; @@ -123,9 +130,7 @@ public class BarcodeService { } public void printLabel( BufferedImage bufferedImage ) throws Exception { - String ipAddr = "172.16.53.32"; - int port = 9100; - Connection connection = new TcpConnection( ipAddr, port ); + Connection connection = new TcpConnection( ipAddress, port ); connection.open(); ZebraPrinter printer = ZebraPrinterFactory.getInstance( connection ); ZebraImage zebraImage = new ZebraImage( bufferedImage ); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index f737fe4..9c396ee 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,20 +1,4 @@ spring: - resources: - chain: - cache: false - strategy: - content: - enabled: true - paths: /** - html-application-cache: true - enabled: true - cache: - period: 0 - static-locations: classpath:/static/ - thymeleaf: - check-template-location: true - cache: false - prefix: classpath:/templates/ uinddatasource: jdbcUrl: jdbc:mysql://192.168.90.147:3306 username: utopia @@ -44,23 +28,7 @@ spring: pool-name: CTPPool leak-detection-threshold: 2000 -server: - servlet: - context-path: /ctp - tomcat: - remoteip: - remote-ip-header: X-FORWARDED-FOR - max-parameter-count: 50000 - port: 8080 - compression: - enabled: true - mime-types: text/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/json, application/xml - min-response-size: 2KB - -thymeleaf-layout-dialect: - version: 2.1.1 - ctp: - cipher: - key: BC87A69BFCEC4A71E73B8DCCC4F14 - seed-value : 7XYXo8Qq6D \ No newline at end of file + printer: + ipAdd: 192.168.90.160 + port: 9100 \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 2e50966..2607c37 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,20 +1,4 @@ spring: - resources: - chain: - cache: false - strategy: - content: - enabled: true - paths: /** - html-application-cache: true - enabled: true - cache: - period: 0 - static-locations: classpath:/static/ - thymeleaf: - check-template-location: true - cache: false - prefix: classpath:/templates/ uinddatasource: jdbcUrl: jdbc:mysql://localhost:3306 username: root @@ -44,23 +28,7 @@ spring: pool-name: CTPPool leak-detection-threshold: 2000 -server: - servlet: - context-path: /ctp - tomcat: - remoteip: - remote-ip-header: X-FORWARDED-FOR - max-parameter-count: 50000 - port: 8080 - compression: - enabled: true - mime-types: text/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/json, application/xml - min-response-size: 2KB - -thymeleaf-layout-dialect: - version: 2.1.1 - ctp: - cipher: - key: BC87A69BFCEC4A71E73B8DCCC4F14 - seed-value : 7XYXo8Qq6D \ No newline at end of file + printer: + ipAdd: 172.16.53.32 + port: 9100 \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b472387..48d0837 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -6,3 +6,41 @@ application: spring: profiles: active: dev + + resources: + chain: + cache: false + strategy: + content: + enabled: true + paths: /** + html-application-cache: true + enabled: true + cache: + period: 0 + static-locations: classpath:/static/ + thymeleaf: + check-template-location: true + cache: false + prefix: classpath:/templates/ + +server: + servlet: + context-path: /ctp + tomcat: + remoteip: + remote-ip-header: X-FORWARDED-FOR + max-parameter-count: 50000 + port: 8080 + compression: + enabled: true + mime-types: text/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/json, application/xml + min-response-size: 2KB + +thymeleaf-layout-dialect: + version: 2.1.1 + +ctp: + cipher: + key: BC87A69BFCEC4A71E73B8DCCC4F14 + seed-value : 7XYXo8Qq6D \ No newline at end of file -- 2.40.1